documentation.d.ts 3.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014
  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. readonly isAsync: boolean;
  7124. readonly isReady: boolean;
  7125. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7126. }
  7127. }
  7128. declare module BABYLON {
  7129. interface ThinEngine {
  7130. /**
  7131. * Create an uniform buffer
  7132. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7133. * @param elements defines the content of the uniform buffer
  7134. * @returns the webGL uniform buffer
  7135. */
  7136. createUniformBuffer(elements: FloatArray): DataBuffer;
  7137. /**
  7138. * Create a dynamic uniform buffer
  7139. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7140. * @param elements defines the content of the uniform buffer
  7141. * @returns the webGL uniform buffer
  7142. */
  7143. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7144. /**
  7145. * Update an existing uniform buffer
  7146. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7147. * @param uniformBuffer defines the target uniform buffer
  7148. * @param elements defines the content to update
  7149. * @param offset defines the offset in the uniform buffer where update should start
  7150. * @param count defines the size of the data to update
  7151. */
  7152. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7153. /**
  7154. * Bind an uniform buffer to the current webGL context
  7155. * @param buffer defines the buffer to bind
  7156. */
  7157. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7158. /**
  7159. * Bind a buffer to the current webGL context at a given location
  7160. * @param buffer defines the buffer to bind
  7161. * @param location defines the index where to bind the buffer
  7162. */
  7163. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7164. /**
  7165. * Bind a specific block at a given index in a specific shader program
  7166. * @param pipelineContext defines the pipeline context to use
  7167. * @param blockName defines the block name
  7168. * @param index defines the index where to bind the block
  7169. */
  7170. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7171. }
  7172. }
  7173. declare module BABYLON {
  7174. /**
  7175. * Uniform buffer objects.
  7176. *
  7177. * Handles blocks of uniform on the GPU.
  7178. *
  7179. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7180. *
  7181. * For more information, please refer to :
  7182. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7183. */
  7184. export class UniformBuffer {
  7185. private _engine;
  7186. private _buffer;
  7187. private _data;
  7188. private _bufferData;
  7189. private _dynamic?;
  7190. private _uniformLocations;
  7191. private _uniformSizes;
  7192. private _uniformLocationPointer;
  7193. private _needSync;
  7194. private _noUBO;
  7195. private _currentEffect;
  7196. /** @hidden */
  7197. _alreadyBound: boolean;
  7198. private static _MAX_UNIFORM_SIZE;
  7199. private static _tempBuffer;
  7200. /**
  7201. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7202. * This is dynamic to allow compat with webgl 1 and 2.
  7203. * You will need to pass the name of the uniform as well as the value.
  7204. */
  7205. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7206. /**
  7207. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7208. * This is dynamic to allow compat with webgl 1 and 2.
  7209. * You will need to pass the name of the uniform as well as the value.
  7210. */
  7211. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7212. /**
  7213. * Lambda to Update a single float in a uniform buffer.
  7214. * This is dynamic to allow compat with webgl 1 and 2.
  7215. * You will need to pass the name of the uniform as well as the value.
  7216. */
  7217. updateFloat: (name: string, x: number) => void;
  7218. /**
  7219. * Lambda to Update a vec2 of float in a uniform buffer.
  7220. * This is dynamic to allow compat with webgl 1 and 2.
  7221. * You will need to pass the name of the uniform as well as the value.
  7222. */
  7223. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7224. /**
  7225. * Lambda to Update a vec3 of float in a uniform buffer.
  7226. * This is dynamic to allow compat with webgl 1 and 2.
  7227. * You will need to pass the name of the uniform as well as the value.
  7228. */
  7229. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7230. /**
  7231. * Lambda to Update a vec4 of float in a uniform buffer.
  7232. * This is dynamic to allow compat with webgl 1 and 2.
  7233. * You will need to pass the name of the uniform as well as the value.
  7234. */
  7235. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7236. /**
  7237. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7238. * This is dynamic to allow compat with webgl 1 and 2.
  7239. * You will need to pass the name of the uniform as well as the value.
  7240. */
  7241. updateMatrix: (name: string, mat: Matrix) => void;
  7242. /**
  7243. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7244. * This is dynamic to allow compat with webgl 1 and 2.
  7245. * You will need to pass the name of the uniform as well as the value.
  7246. */
  7247. updateVector3: (name: string, vector: Vector3) => void;
  7248. /**
  7249. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7250. * This is dynamic to allow compat with webgl 1 and 2.
  7251. * You will need to pass the name of the uniform as well as the value.
  7252. */
  7253. updateVector4: (name: string, vector: Vector4) => void;
  7254. /**
  7255. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7256. * This is dynamic to allow compat with webgl 1 and 2.
  7257. * You will need to pass the name of the uniform as well as the value.
  7258. */
  7259. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7260. /**
  7261. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7262. * This is dynamic to allow compat with webgl 1 and 2.
  7263. * You will need to pass the name of the uniform as well as the value.
  7264. */
  7265. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7266. /**
  7267. * Instantiates a new Uniform buffer objects.
  7268. *
  7269. * Handles blocks of uniform on the GPU.
  7270. *
  7271. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7272. *
  7273. * For more information, please refer to :
  7274. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7275. * @param engine Define the engine the buffer is associated with
  7276. * @param data Define the data contained in the buffer
  7277. * @param dynamic Define if the buffer is updatable
  7278. */
  7279. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7280. /**
  7281. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7282. * or just falling back on setUniformXXX calls.
  7283. */
  7284. readonly useUbo: boolean;
  7285. /**
  7286. * Indicates if the WebGL underlying uniform buffer is in sync
  7287. * with the javascript cache data.
  7288. */
  7289. readonly isSync: boolean;
  7290. /**
  7291. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7292. * Also, a dynamic UniformBuffer will disable cache verification and always
  7293. * update the underlying WebGL uniform buffer to the GPU.
  7294. * @returns if Dynamic, otherwise false
  7295. */
  7296. isDynamic(): boolean;
  7297. /**
  7298. * The data cache on JS side.
  7299. * @returns the underlying data as a float array
  7300. */
  7301. getData(): Float32Array;
  7302. /**
  7303. * The underlying WebGL Uniform buffer.
  7304. * @returns the webgl buffer
  7305. */
  7306. getBuffer(): Nullable<DataBuffer>;
  7307. /**
  7308. * std140 layout specifies how to align data within an UBO structure.
  7309. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7310. * for specs.
  7311. */
  7312. private _fillAlignment;
  7313. /**
  7314. * Adds an uniform in the buffer.
  7315. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7316. * for the layout to be correct !
  7317. * @param name Name of the uniform, as used in the uniform block in the shader.
  7318. * @param size Data size, or data directly.
  7319. */
  7320. addUniform(name: string, size: number | number[]): void;
  7321. /**
  7322. * Adds a Matrix 4x4 to the uniform buffer.
  7323. * @param name Name of the uniform, as used in the uniform block in the shader.
  7324. * @param mat A 4x4 matrix.
  7325. */
  7326. addMatrix(name: string, mat: Matrix): void;
  7327. /**
  7328. * Adds a vec2 to the uniform buffer.
  7329. * @param name Name of the uniform, as used in the uniform block in the shader.
  7330. * @param x Define the x component value of the vec2
  7331. * @param y Define the y component value of the vec2
  7332. */
  7333. addFloat2(name: string, x: number, y: number): void;
  7334. /**
  7335. * Adds a vec3 to the uniform buffer.
  7336. * @param name Name of the uniform, as used in the uniform block in the shader.
  7337. * @param x Define the x component value of the vec3
  7338. * @param y Define the y component value of the vec3
  7339. * @param z Define the z component value of the vec3
  7340. */
  7341. addFloat3(name: string, x: number, y: number, z: number): void;
  7342. /**
  7343. * Adds a vec3 to the uniform buffer.
  7344. * @param name Name of the uniform, as used in the uniform block in the shader.
  7345. * @param color Define the vec3 from a Color
  7346. */
  7347. addColor3(name: string, color: Color3): void;
  7348. /**
  7349. * Adds a vec4 to the uniform buffer.
  7350. * @param name Name of the uniform, as used in the uniform block in the shader.
  7351. * @param color Define the rgb components from a Color
  7352. * @param alpha Define the a component of the vec4
  7353. */
  7354. addColor4(name: string, color: Color3, alpha: number): void;
  7355. /**
  7356. * Adds a vec3 to the uniform buffer.
  7357. * @param name Name of the uniform, as used in the uniform block in the shader.
  7358. * @param vector Define the vec3 components from a Vector
  7359. */
  7360. addVector3(name: string, vector: Vector3): void;
  7361. /**
  7362. * Adds a Matrix 3x3 to the uniform buffer.
  7363. * @param name Name of the uniform, as used in the uniform block in the shader.
  7364. */
  7365. addMatrix3x3(name: string): void;
  7366. /**
  7367. * Adds a Matrix 2x2 to the uniform buffer.
  7368. * @param name Name of the uniform, as used in the uniform block in the shader.
  7369. */
  7370. addMatrix2x2(name: string): void;
  7371. /**
  7372. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7373. */
  7374. create(): void;
  7375. /** @hidden */
  7376. _rebuild(): void;
  7377. /**
  7378. * Updates the WebGL Uniform Buffer on the GPU.
  7379. * If the `dynamic` flag is set to true, no cache comparison is done.
  7380. * Otherwise, the buffer will be updated only if the cache differs.
  7381. */
  7382. update(): void;
  7383. /**
  7384. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7385. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7386. * @param data Define the flattened data
  7387. * @param size Define the size of the data.
  7388. */
  7389. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7390. private _valueCache;
  7391. private _cacheMatrix;
  7392. private _updateMatrix3x3ForUniform;
  7393. private _updateMatrix3x3ForEffect;
  7394. private _updateMatrix2x2ForEffect;
  7395. private _updateMatrix2x2ForUniform;
  7396. private _updateFloatForEffect;
  7397. private _updateFloatForUniform;
  7398. private _updateFloat2ForEffect;
  7399. private _updateFloat2ForUniform;
  7400. private _updateFloat3ForEffect;
  7401. private _updateFloat3ForUniform;
  7402. private _updateFloat4ForEffect;
  7403. private _updateFloat4ForUniform;
  7404. private _updateMatrixForEffect;
  7405. private _updateMatrixForUniform;
  7406. private _updateVector3ForEffect;
  7407. private _updateVector3ForUniform;
  7408. private _updateVector4ForEffect;
  7409. private _updateVector4ForUniform;
  7410. private _updateColor3ForEffect;
  7411. private _updateColor3ForUniform;
  7412. private _updateColor4ForEffect;
  7413. private _updateColor4ForUniform;
  7414. /**
  7415. * Sets a sampler uniform on the effect.
  7416. * @param name Define the name of the sampler.
  7417. * @param texture Define the texture to set in the sampler
  7418. */
  7419. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7420. /**
  7421. * Directly updates the value of the uniform in the cache AND on the GPU.
  7422. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7423. * @param data Define the flattened data
  7424. */
  7425. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7426. /**
  7427. * Binds this uniform buffer to an effect.
  7428. * @param effect Define the effect to bind the buffer to
  7429. * @param name Name of the uniform block in the shader.
  7430. */
  7431. bindToEffect(effect: Effect, name: string): void;
  7432. /**
  7433. * Disposes the uniform buffer.
  7434. */
  7435. dispose(): void;
  7436. }
  7437. }
  7438. declare module BABYLON {
  7439. /**
  7440. * Enum that determines the text-wrapping mode to use.
  7441. */
  7442. export enum InspectableType {
  7443. /**
  7444. * Checkbox for booleans
  7445. */
  7446. Checkbox = 0,
  7447. /**
  7448. * Sliders for numbers
  7449. */
  7450. Slider = 1,
  7451. /**
  7452. * Vector3
  7453. */
  7454. Vector3 = 2,
  7455. /**
  7456. * Quaternions
  7457. */
  7458. Quaternion = 3,
  7459. /**
  7460. * Color3
  7461. */
  7462. Color3 = 4,
  7463. /**
  7464. * String
  7465. */
  7466. String = 5
  7467. }
  7468. /**
  7469. * Interface used to define custom inspectable properties.
  7470. * This interface is used by the inspector to display custom property grids
  7471. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7472. */
  7473. export interface IInspectable {
  7474. /**
  7475. * Gets the label to display
  7476. */
  7477. label: string;
  7478. /**
  7479. * Gets the name of the property to edit
  7480. */
  7481. propertyName: string;
  7482. /**
  7483. * Gets the type of the editor to use
  7484. */
  7485. type: InspectableType;
  7486. /**
  7487. * Gets the minimum value of the property when using in "slider" mode
  7488. */
  7489. min?: number;
  7490. /**
  7491. * Gets the maximum value of the property when using in "slider" mode
  7492. */
  7493. max?: number;
  7494. /**
  7495. * Gets the setp to use when using in "slider" mode
  7496. */
  7497. step?: number;
  7498. }
  7499. }
  7500. declare module BABYLON {
  7501. /**
  7502. * Class used to provide helper for timing
  7503. */
  7504. export class TimingTools {
  7505. /**
  7506. * Polyfill for setImmediate
  7507. * @param action defines the action to execute after the current execution block
  7508. */
  7509. static SetImmediate(action: () => void): void;
  7510. }
  7511. }
  7512. declare module BABYLON {
  7513. /**
  7514. * Class used to enable instatition of objects by class name
  7515. */
  7516. export class InstantiationTools {
  7517. /**
  7518. * Use this object to register external classes like custom textures or material
  7519. * to allow the laoders to instantiate them
  7520. */
  7521. static RegisteredExternalClasses: {
  7522. [key: string]: Object;
  7523. };
  7524. /**
  7525. * Tries to instantiate a new object from a given class name
  7526. * @param className defines the class name to instantiate
  7527. * @returns the new object or null if the system was not able to do the instantiation
  7528. */
  7529. static Instantiate(className: string): any;
  7530. }
  7531. }
  7532. declare module BABYLON {
  7533. /**
  7534. * Define options used to create a depth texture
  7535. */
  7536. export class DepthTextureCreationOptions {
  7537. /** Specifies whether or not a stencil should be allocated in the texture */
  7538. generateStencil?: boolean;
  7539. /** Specifies whether or not bilinear filtering is enable on the texture */
  7540. bilinearFiltering?: boolean;
  7541. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7542. comparisonFunction?: number;
  7543. /** Specifies if the created texture is a cube texture */
  7544. isCube?: boolean;
  7545. }
  7546. }
  7547. declare module BABYLON {
  7548. interface ThinEngine {
  7549. /**
  7550. * Creates a depth stencil cube texture.
  7551. * This is only available in WebGL 2.
  7552. * @param size The size of face edge in the cube texture.
  7553. * @param options The options defining the cube texture.
  7554. * @returns The cube texture
  7555. */
  7556. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7557. /**
  7558. * Creates a cube texture
  7559. * @param rootUrl defines the url where the files to load is located
  7560. * @param scene defines the current scene
  7561. * @param files defines the list of files to load (1 per face)
  7562. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7563. * @param onLoad defines an optional callback raised when the texture is loaded
  7564. * @param onError defines an optional callback raised if there is an issue to load the texture
  7565. * @param format defines the format of the data
  7566. * @param forcedExtension defines the extension to use to pick the right loader
  7567. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7568. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7569. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7570. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7571. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7572. * @returns the cube texture as an InternalTexture
  7573. */
  7574. 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;
  7575. /**
  7576. * Creates a cube texture
  7577. * @param rootUrl defines the url where the files to load is located
  7578. * @param scene defines the current scene
  7579. * @param files defines the list of files to load (1 per face)
  7580. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7581. * @param onLoad defines an optional callback raised when the texture is loaded
  7582. * @param onError defines an optional callback raised if there is an issue to load the texture
  7583. * @param format defines the format of the data
  7584. * @param forcedExtension defines the extension to use to pick the right loader
  7585. * @returns the cube texture as an InternalTexture
  7586. */
  7587. 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;
  7588. /**
  7589. * Creates a cube texture
  7590. * @param rootUrl defines the url where the files to load is located
  7591. * @param scene defines the current scene
  7592. * @param files defines the list of files to load (1 per face)
  7593. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7594. * @param onLoad defines an optional callback raised when the texture is loaded
  7595. * @param onError defines an optional callback raised if there is an issue to load the texture
  7596. * @param format defines the format of the data
  7597. * @param forcedExtension defines the extension to use to pick the right loader
  7598. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7599. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7600. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7601. * @returns the cube texture as an InternalTexture
  7602. */
  7603. 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;
  7604. /** @hidden */
  7605. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7606. /** @hidden */
  7607. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7608. /** @hidden */
  7609. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7610. /** @hidden */
  7611. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7612. /**
  7613. * @hidden
  7614. */
  7615. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7616. }
  7617. }
  7618. declare module BABYLON {
  7619. /**
  7620. * Class for creating a cube texture
  7621. */
  7622. export class CubeTexture extends BaseTexture {
  7623. private _delayedOnLoad;
  7624. /**
  7625. * The url of the texture
  7626. */
  7627. url: string;
  7628. /**
  7629. * Gets or sets the center of the bounding box associated with the cube texture.
  7630. * It must define where the camera used to render the texture was set
  7631. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7632. */
  7633. boundingBoxPosition: Vector3;
  7634. private _boundingBoxSize;
  7635. /**
  7636. * Gets or sets the size of the bounding box associated with the cube texture
  7637. * When defined, the cubemap will switch to local mode
  7638. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7639. * @example https://www.babylonjs-playground.com/#RNASML
  7640. */
  7641. /**
  7642. * Returns the bounding box size
  7643. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7644. */
  7645. boundingBoxSize: Vector3;
  7646. protected _rotationY: number;
  7647. /**
  7648. * Sets texture matrix rotation angle around Y axis in radians.
  7649. */
  7650. /**
  7651. * Gets texture matrix rotation angle around Y axis radians.
  7652. */
  7653. rotationY: number;
  7654. /**
  7655. * Are mip maps generated for this texture or not.
  7656. */
  7657. readonly noMipmap: boolean;
  7658. private _noMipmap;
  7659. private _files;
  7660. protected _forcedExtension: Nullable<string>;
  7661. private _extensions;
  7662. private _textureMatrix;
  7663. private _format;
  7664. private _createPolynomials;
  7665. /** @hidden */
  7666. _prefiltered: boolean;
  7667. /**
  7668. * Creates a cube texture from an array of image urls
  7669. * @param files defines an array of image urls
  7670. * @param scene defines the hosting scene
  7671. * @param noMipmap specifies if mip maps are not used
  7672. * @returns a cube texture
  7673. */
  7674. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7675. /**
  7676. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7677. * @param url defines the url of the prefiltered texture
  7678. * @param scene defines the scene the texture is attached to
  7679. * @param forcedExtension defines the extension of the file if different from the url
  7680. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7681. * @return the prefiltered texture
  7682. */
  7683. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7684. /**
  7685. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7686. * as prefiltered data.
  7687. * @param rootUrl defines the url of the texture or the root name of the six images
  7688. * @param scene defines the scene the texture is attached to
  7689. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7690. * @param noMipmap defines if mipmaps should be created or not
  7691. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7692. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7693. * @param onError defines a callback triggered in case of error during load
  7694. * @param format defines the internal format to use for the texture once loaded
  7695. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7696. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7697. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7698. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7699. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7700. * @return the cube texture
  7701. */
  7702. 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);
  7703. /**
  7704. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7705. */
  7706. readonly isPrefiltered: boolean;
  7707. /**
  7708. * Get the current class name of the texture useful for serialization or dynamic coding.
  7709. * @returns "CubeTexture"
  7710. */
  7711. getClassName(): string;
  7712. /**
  7713. * Update the url (and optional buffer) of this texture if url was null during construction.
  7714. * @param url the url of the texture
  7715. * @param forcedExtension defines the extension to use
  7716. * @param onLoad callback called when the texture is loaded (defaults to null)
  7717. */
  7718. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7719. /**
  7720. * Delays loading of the cube texture
  7721. * @param forcedExtension defines the extension to use
  7722. */
  7723. delayLoad(forcedExtension?: string): void;
  7724. /**
  7725. * Returns the reflection texture matrix
  7726. * @returns the reflection texture matrix
  7727. */
  7728. getReflectionTextureMatrix(): Matrix;
  7729. /**
  7730. * Sets the reflection texture matrix
  7731. * @param value Reflection texture matrix
  7732. */
  7733. setReflectionTextureMatrix(value: Matrix): void;
  7734. /**
  7735. * Parses text to create a cube texture
  7736. * @param parsedTexture define the serialized text to read from
  7737. * @param scene defines the hosting scene
  7738. * @param rootUrl defines the root url of the cube texture
  7739. * @returns a cube texture
  7740. */
  7741. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7742. /**
  7743. * Makes a clone, or deep copy, of the cube texture
  7744. * @returns a new cube texture
  7745. */
  7746. clone(): CubeTexture;
  7747. }
  7748. }
  7749. declare module BABYLON {
  7750. /**
  7751. * Manages the defines for the Material
  7752. */
  7753. export class MaterialDefines {
  7754. /** @hidden */
  7755. protected _keys: string[];
  7756. private _isDirty;
  7757. /** @hidden */
  7758. _renderId: number;
  7759. /** @hidden */
  7760. _areLightsDirty: boolean;
  7761. /** @hidden */
  7762. _areLightsDisposed: boolean;
  7763. /** @hidden */
  7764. _areAttributesDirty: boolean;
  7765. /** @hidden */
  7766. _areTexturesDirty: boolean;
  7767. /** @hidden */
  7768. _areFresnelDirty: boolean;
  7769. /** @hidden */
  7770. _areMiscDirty: boolean;
  7771. /** @hidden */
  7772. _areImageProcessingDirty: boolean;
  7773. /** @hidden */
  7774. _normals: boolean;
  7775. /** @hidden */
  7776. _uvs: boolean;
  7777. /** @hidden */
  7778. _needNormals: boolean;
  7779. /** @hidden */
  7780. _needUVs: boolean;
  7781. [id: string]: any;
  7782. /**
  7783. * Specifies if the material needs to be re-calculated
  7784. */
  7785. readonly isDirty: boolean;
  7786. /**
  7787. * Marks the material to indicate that it has been re-calculated
  7788. */
  7789. markAsProcessed(): void;
  7790. /**
  7791. * Marks the material to indicate that it needs to be re-calculated
  7792. */
  7793. markAsUnprocessed(): void;
  7794. /**
  7795. * Marks the material to indicate all of its defines need to be re-calculated
  7796. */
  7797. markAllAsDirty(): void;
  7798. /**
  7799. * Marks the material to indicate that image processing needs to be re-calculated
  7800. */
  7801. markAsImageProcessingDirty(): void;
  7802. /**
  7803. * Marks the material to indicate the lights need to be re-calculated
  7804. * @param disposed Defines whether the light is dirty due to dispose or not
  7805. */
  7806. markAsLightDirty(disposed?: boolean): void;
  7807. /**
  7808. * Marks the attribute state as changed
  7809. */
  7810. markAsAttributesDirty(): void;
  7811. /**
  7812. * Marks the texture state as changed
  7813. */
  7814. markAsTexturesDirty(): void;
  7815. /**
  7816. * Marks the fresnel state as changed
  7817. */
  7818. markAsFresnelDirty(): void;
  7819. /**
  7820. * Marks the misc state as changed
  7821. */
  7822. markAsMiscDirty(): void;
  7823. /**
  7824. * Rebuilds the material defines
  7825. */
  7826. rebuild(): void;
  7827. /**
  7828. * Specifies if two material defines are equal
  7829. * @param other - A material define instance to compare to
  7830. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7831. */
  7832. isEqual(other: MaterialDefines): boolean;
  7833. /**
  7834. * Clones this instance's defines to another instance
  7835. * @param other - material defines to clone values to
  7836. */
  7837. cloneTo(other: MaterialDefines): void;
  7838. /**
  7839. * Resets the material define values
  7840. */
  7841. reset(): void;
  7842. /**
  7843. * Converts the material define values to a string
  7844. * @returns - String of material define information
  7845. */
  7846. toString(): string;
  7847. }
  7848. }
  7849. declare module BABYLON {
  7850. /**
  7851. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7852. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7853. * 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;
  7854. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7855. */
  7856. export class ColorCurves {
  7857. private _dirty;
  7858. private _tempColor;
  7859. private _globalCurve;
  7860. private _highlightsCurve;
  7861. private _midtonesCurve;
  7862. private _shadowsCurve;
  7863. private _positiveCurve;
  7864. private _negativeCurve;
  7865. private _globalHue;
  7866. private _globalDensity;
  7867. private _globalSaturation;
  7868. private _globalExposure;
  7869. /**
  7870. * Gets the global Hue value.
  7871. * 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).
  7872. */
  7873. /**
  7874. * Sets 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. globalHue: number;
  7878. /**
  7879. * Gets the global Density value.
  7880. * 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.
  7881. * Values less than zero provide a filter of opposite hue.
  7882. */
  7883. /**
  7884. * Sets the global Density value.
  7885. * 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.
  7886. * Values less than zero provide a filter of opposite hue.
  7887. */
  7888. globalDensity: number;
  7889. /**
  7890. * Gets the global Saturation value.
  7891. * 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.
  7892. */
  7893. /**
  7894. * Sets 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. globalSaturation: number;
  7898. /**
  7899. * Gets the global Exposure value.
  7900. * 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.
  7901. */
  7902. /**
  7903. * Sets 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. globalExposure: number;
  7907. private _highlightsHue;
  7908. private _highlightsDensity;
  7909. private _highlightsSaturation;
  7910. private _highlightsExposure;
  7911. /**
  7912. * Gets the highlights Hue value.
  7913. * 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).
  7914. */
  7915. /**
  7916. * Sets 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. highlightsHue: number;
  7920. /**
  7921. * Gets the highlights Density value.
  7922. * 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.
  7923. * Values less than zero provide a filter of opposite hue.
  7924. */
  7925. /**
  7926. * Sets the highlights Density value.
  7927. * 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.
  7928. * Values less than zero provide a filter of opposite hue.
  7929. */
  7930. highlightsDensity: number;
  7931. /**
  7932. * Gets the highlights Saturation value.
  7933. * 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.
  7934. */
  7935. /**
  7936. * Sets 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. highlightsSaturation: number;
  7940. /**
  7941. * Gets the highlights Exposure value.
  7942. * 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.
  7943. */
  7944. /**
  7945. * Sets 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. highlightsExposure: number;
  7949. private _midtonesHue;
  7950. private _midtonesDensity;
  7951. private _midtonesSaturation;
  7952. private _midtonesExposure;
  7953. /**
  7954. * Gets the midtones Hue value.
  7955. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7956. */
  7957. /**
  7958. * Sets 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. midtonesHue: number;
  7962. /**
  7963. * Gets the midtones Density value.
  7964. * 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.
  7965. * Values less than zero provide a filter of opposite hue.
  7966. */
  7967. /**
  7968. * Sets the midtones Density value.
  7969. * 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.
  7970. * Values less than zero provide a filter of opposite hue.
  7971. */
  7972. midtonesDensity: number;
  7973. /**
  7974. * Gets the midtones Saturation value.
  7975. * 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.
  7976. */
  7977. /**
  7978. * Sets 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. midtonesSaturation: number;
  7982. /**
  7983. * Gets the midtones Exposure value.
  7984. * 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.
  7985. */
  7986. /**
  7987. * Sets 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. midtonesExposure: number;
  7991. private _shadowsHue;
  7992. private _shadowsDensity;
  7993. private _shadowsSaturation;
  7994. private _shadowsExposure;
  7995. /**
  7996. * Gets the shadows Hue value.
  7997. * 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).
  7998. */
  7999. /**
  8000. * Sets 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. shadowsHue: number;
  8004. /**
  8005. * Gets the shadows Density value.
  8006. * 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.
  8007. * Values less than zero provide a filter of opposite hue.
  8008. */
  8009. /**
  8010. * Sets the shadows Density value.
  8011. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8012. * Values less than zero provide a filter of opposite hue.
  8013. */
  8014. shadowsDensity: number;
  8015. /**
  8016. * Gets the shadows Saturation value.
  8017. * 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.
  8018. */
  8019. /**
  8020. * Sets 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. shadowsSaturation: number;
  8024. /**
  8025. * Gets the shadows Exposure value.
  8026. * 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.
  8027. */
  8028. /**
  8029. * Sets 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. shadowsExposure: number;
  8033. /**
  8034. * Returns the class name
  8035. * @returns The class name
  8036. */
  8037. getClassName(): string;
  8038. /**
  8039. * Binds the color curves to the shader.
  8040. * @param colorCurves The color curve to bind
  8041. * @param effect The effect to bind to
  8042. * @param positiveUniform The positive uniform shader parameter
  8043. * @param neutralUniform The neutral uniform shader parameter
  8044. * @param negativeUniform The negative uniform shader parameter
  8045. */
  8046. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8047. /**
  8048. * Prepare the list of uniforms associated with the ColorCurves effects.
  8049. * @param uniformsList The list of uniforms used in the effect
  8050. */
  8051. static PrepareUniforms(uniformsList: string[]): void;
  8052. /**
  8053. * Returns color grading data based on a hue, density, saturation and exposure value.
  8054. * @param filterHue The hue of the color filter.
  8055. * @param filterDensity The density of the color filter.
  8056. * @param saturation The saturation.
  8057. * @param exposure The exposure.
  8058. * @param result The result data container.
  8059. */
  8060. private getColorGradingDataToRef;
  8061. /**
  8062. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8063. * @param value The input slider value in range [-100,100].
  8064. * @returns Adjusted value.
  8065. */
  8066. private static applyColorGradingSliderNonlinear;
  8067. /**
  8068. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8069. * @param hue The hue (H) input.
  8070. * @param saturation The saturation (S) input.
  8071. * @param brightness The brightness (B) input.
  8072. * @result An RGBA color represented as Vector4.
  8073. */
  8074. private static fromHSBToRef;
  8075. /**
  8076. * Returns a value clamped between min and max
  8077. * @param value The value to clamp
  8078. * @param min The minimum of value
  8079. * @param max The maximum of value
  8080. * @returns The clamped value.
  8081. */
  8082. private static clamp;
  8083. /**
  8084. * Clones the current color curve instance.
  8085. * @return The cloned curves
  8086. */
  8087. clone(): ColorCurves;
  8088. /**
  8089. * Serializes the current color curve instance to a json representation.
  8090. * @return a JSON representation
  8091. */
  8092. serialize(): any;
  8093. /**
  8094. * Parses the color curve from a json representation.
  8095. * @param source the JSON source to parse
  8096. * @return The parsed curves
  8097. */
  8098. static Parse(source: any): ColorCurves;
  8099. }
  8100. }
  8101. declare module BABYLON {
  8102. /**
  8103. * Interface to follow in your material defines to integrate easily the
  8104. * Image proccessing functions.
  8105. * @hidden
  8106. */
  8107. export interface IImageProcessingConfigurationDefines {
  8108. IMAGEPROCESSING: boolean;
  8109. VIGNETTE: boolean;
  8110. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8111. VIGNETTEBLENDMODEOPAQUE: boolean;
  8112. TONEMAPPING: boolean;
  8113. TONEMAPPING_ACES: boolean;
  8114. CONTRAST: boolean;
  8115. EXPOSURE: boolean;
  8116. COLORCURVES: boolean;
  8117. COLORGRADING: boolean;
  8118. COLORGRADING3D: boolean;
  8119. SAMPLER3DGREENDEPTH: boolean;
  8120. SAMPLER3DBGRMAP: boolean;
  8121. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8122. }
  8123. /**
  8124. * @hidden
  8125. */
  8126. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8127. IMAGEPROCESSING: boolean;
  8128. VIGNETTE: boolean;
  8129. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8130. VIGNETTEBLENDMODEOPAQUE: boolean;
  8131. TONEMAPPING: boolean;
  8132. TONEMAPPING_ACES: boolean;
  8133. CONTRAST: boolean;
  8134. COLORCURVES: boolean;
  8135. COLORGRADING: boolean;
  8136. COLORGRADING3D: boolean;
  8137. SAMPLER3DGREENDEPTH: boolean;
  8138. SAMPLER3DBGRMAP: boolean;
  8139. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8140. EXPOSURE: boolean;
  8141. constructor();
  8142. }
  8143. /**
  8144. * This groups together the common properties used for image processing either in direct forward pass
  8145. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8146. * or not.
  8147. */
  8148. export class ImageProcessingConfiguration {
  8149. /**
  8150. * Default tone mapping applied in BabylonJS.
  8151. */
  8152. static readonly TONEMAPPING_STANDARD: number;
  8153. /**
  8154. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8155. * to other engines rendering to increase portability.
  8156. */
  8157. static readonly TONEMAPPING_ACES: number;
  8158. /**
  8159. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8160. */
  8161. colorCurves: Nullable<ColorCurves>;
  8162. private _colorCurvesEnabled;
  8163. /**
  8164. * Gets wether the color curves effect is enabled.
  8165. */
  8166. /**
  8167. * Sets wether the color curves effect is enabled.
  8168. */
  8169. colorCurvesEnabled: boolean;
  8170. private _colorGradingTexture;
  8171. /**
  8172. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8173. */
  8174. /**
  8175. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8176. */
  8177. colorGradingTexture: Nullable<BaseTexture>;
  8178. private _colorGradingEnabled;
  8179. /**
  8180. * Gets wether the color grading effect is enabled.
  8181. */
  8182. /**
  8183. * Sets wether the color grading effect is enabled.
  8184. */
  8185. colorGradingEnabled: boolean;
  8186. private _colorGradingWithGreenDepth;
  8187. /**
  8188. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8189. */
  8190. /**
  8191. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8192. */
  8193. colorGradingWithGreenDepth: boolean;
  8194. private _colorGradingBGR;
  8195. /**
  8196. * Gets wether the color grading texture contains BGR values.
  8197. */
  8198. /**
  8199. * Sets wether the color grading texture contains BGR values.
  8200. */
  8201. colorGradingBGR: boolean;
  8202. /** @hidden */
  8203. _exposure: number;
  8204. /**
  8205. * Gets the Exposure used in the effect.
  8206. */
  8207. /**
  8208. * Sets the Exposure used in the effect.
  8209. */
  8210. exposure: number;
  8211. private _toneMappingEnabled;
  8212. /**
  8213. * Gets wether the tone mapping effect is enabled.
  8214. */
  8215. /**
  8216. * Sets wether the tone mapping effect is enabled.
  8217. */
  8218. toneMappingEnabled: boolean;
  8219. private _toneMappingType;
  8220. /**
  8221. * Gets the type of tone mapping effect.
  8222. */
  8223. /**
  8224. * Sets the type of tone mapping effect used in BabylonJS.
  8225. */
  8226. toneMappingType: number;
  8227. protected _contrast: number;
  8228. /**
  8229. * Gets the contrast used in the effect.
  8230. */
  8231. /**
  8232. * Sets the contrast used in the effect.
  8233. */
  8234. contrast: number;
  8235. /**
  8236. * Vignette stretch size.
  8237. */
  8238. vignetteStretch: number;
  8239. /**
  8240. * Vignette centre X Offset.
  8241. */
  8242. vignetteCentreX: number;
  8243. /**
  8244. * Vignette centre Y Offset.
  8245. */
  8246. vignetteCentreY: number;
  8247. /**
  8248. * Vignette weight or intensity of the vignette effect.
  8249. */
  8250. vignetteWeight: number;
  8251. /**
  8252. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8253. * if vignetteEnabled is set to true.
  8254. */
  8255. vignetteColor: Color4;
  8256. /**
  8257. * Camera field of view used by the Vignette effect.
  8258. */
  8259. vignetteCameraFov: number;
  8260. private _vignetteBlendMode;
  8261. /**
  8262. * Gets the vignette blend mode allowing different kind of effect.
  8263. */
  8264. /**
  8265. * Sets the vignette blend mode allowing different kind of effect.
  8266. */
  8267. vignetteBlendMode: number;
  8268. private _vignetteEnabled;
  8269. /**
  8270. * Gets wether the vignette effect is enabled.
  8271. */
  8272. /**
  8273. * Sets wether the vignette effect is enabled.
  8274. */
  8275. vignetteEnabled: boolean;
  8276. private _applyByPostProcess;
  8277. /**
  8278. * Gets wether the image processing is applied through a post process or not.
  8279. */
  8280. /**
  8281. * Sets wether the image processing is applied through a post process or not.
  8282. */
  8283. applyByPostProcess: boolean;
  8284. private _isEnabled;
  8285. /**
  8286. * Gets wether the image processing is enabled or not.
  8287. */
  8288. /**
  8289. * Sets wether the image processing is enabled or not.
  8290. */
  8291. isEnabled: boolean;
  8292. /**
  8293. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8294. */
  8295. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8296. /**
  8297. * Method called each time the image processing information changes requires to recompile the effect.
  8298. */
  8299. protected _updateParameters(): void;
  8300. /**
  8301. * Gets the current class name.
  8302. * @return "ImageProcessingConfiguration"
  8303. */
  8304. getClassName(): string;
  8305. /**
  8306. * Prepare the list of uniforms associated with the Image Processing effects.
  8307. * @param uniforms The list of uniforms used in the effect
  8308. * @param defines the list of defines currently in use
  8309. */
  8310. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8311. /**
  8312. * Prepare the list of samplers associated with the Image Processing effects.
  8313. * @param samplersList The list of uniforms used in the effect
  8314. * @param defines the list of defines currently in use
  8315. */
  8316. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8317. /**
  8318. * Prepare the list of defines associated to the shader.
  8319. * @param defines the list of defines to complete
  8320. * @param forPostProcess Define if we are currently in post process mode or not
  8321. */
  8322. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8323. /**
  8324. * Returns true if all the image processing information are ready.
  8325. * @returns True if ready, otherwise, false
  8326. */
  8327. isReady(): boolean;
  8328. /**
  8329. * Binds the image processing to the shader.
  8330. * @param effect The effect to bind to
  8331. * @param overrideAspectRatio Override the aspect ratio of the effect
  8332. */
  8333. bind(effect: Effect, overrideAspectRatio?: number): void;
  8334. /**
  8335. * Clones the current image processing instance.
  8336. * @return The cloned image processing
  8337. */
  8338. clone(): ImageProcessingConfiguration;
  8339. /**
  8340. * Serializes the current image processing instance to a json representation.
  8341. * @return a JSON representation
  8342. */
  8343. serialize(): any;
  8344. /**
  8345. * Parses the image processing from a json representation.
  8346. * @param source the JSON source to parse
  8347. * @return The parsed image processing
  8348. */
  8349. static Parse(source: any): ImageProcessingConfiguration;
  8350. private static _VIGNETTEMODE_MULTIPLY;
  8351. private static _VIGNETTEMODE_OPAQUE;
  8352. /**
  8353. * Used to apply the vignette as a mix with the pixel color.
  8354. */
  8355. static readonly VIGNETTEMODE_MULTIPLY: number;
  8356. /**
  8357. * Used to apply the vignette as a replacement of the pixel color.
  8358. */
  8359. static readonly VIGNETTEMODE_OPAQUE: number;
  8360. }
  8361. }
  8362. declare module BABYLON {
  8363. /** @hidden */
  8364. export var postprocessVertexShader: {
  8365. name: string;
  8366. shader: string;
  8367. };
  8368. }
  8369. declare module BABYLON {
  8370. interface ThinEngine {
  8371. /**
  8372. * Creates a new render target texture
  8373. * @param size defines the size of the texture
  8374. * @param options defines the options used to create the texture
  8375. * @returns a new render target texture stored in an InternalTexture
  8376. */
  8377. createRenderTargetTexture(size: number | {
  8378. width: number;
  8379. height: number;
  8380. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8381. /**
  8382. * Creates a depth stencil texture.
  8383. * This is only available in WebGL 2 or with the depth texture extension available.
  8384. * @param size The size of face edge in the texture.
  8385. * @param options The options defining the texture.
  8386. * @returns The texture
  8387. */
  8388. createDepthStencilTexture(size: number | {
  8389. width: number;
  8390. height: number;
  8391. }, options: DepthTextureCreationOptions): InternalTexture;
  8392. /** @hidden */
  8393. _createDepthStencilTexture(size: number | {
  8394. width: number;
  8395. height: number;
  8396. }, options: DepthTextureCreationOptions): InternalTexture;
  8397. }
  8398. }
  8399. declare module BABYLON {
  8400. /** Defines supported spaces */
  8401. export enum Space {
  8402. /** Local (object) space */
  8403. LOCAL = 0,
  8404. /** World space */
  8405. WORLD = 1,
  8406. /** Bone space */
  8407. BONE = 2
  8408. }
  8409. /** Defines the 3 main axes */
  8410. export class Axis {
  8411. /** X axis */
  8412. static X: Vector3;
  8413. /** Y axis */
  8414. static Y: Vector3;
  8415. /** Z axis */
  8416. static Z: Vector3;
  8417. }
  8418. }
  8419. declare module BABYLON {
  8420. /**
  8421. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8422. * This is the base of the follow, arc rotate cameras and Free camera
  8423. * @see http://doc.babylonjs.com/features/cameras
  8424. */
  8425. export class TargetCamera extends Camera {
  8426. private static _RigCamTransformMatrix;
  8427. private static _TargetTransformMatrix;
  8428. private static _TargetFocalPoint;
  8429. /**
  8430. * Define the current direction the camera is moving to
  8431. */
  8432. cameraDirection: Vector3;
  8433. /**
  8434. * Define the current rotation the camera is rotating to
  8435. */
  8436. cameraRotation: Vector2;
  8437. /**
  8438. * When set, the up vector of the camera will be updated by the rotation of the camera
  8439. */
  8440. updateUpVectorFromRotation: boolean;
  8441. private _tmpQuaternion;
  8442. /**
  8443. * Define the current rotation of the camera
  8444. */
  8445. rotation: Vector3;
  8446. /**
  8447. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8448. */
  8449. rotationQuaternion: Quaternion;
  8450. /**
  8451. * Define the current speed of the camera
  8452. */
  8453. speed: number;
  8454. /**
  8455. * Add constraint to the camera to prevent it to move freely in all directions and
  8456. * around all axis.
  8457. */
  8458. noRotationConstraint: boolean;
  8459. /**
  8460. * Define the current target of the camera as an object or a position.
  8461. */
  8462. lockedTarget: any;
  8463. /** @hidden */
  8464. _currentTarget: Vector3;
  8465. /** @hidden */
  8466. _initialFocalDistance: number;
  8467. /** @hidden */
  8468. _viewMatrix: Matrix;
  8469. /** @hidden */
  8470. _camMatrix: Matrix;
  8471. /** @hidden */
  8472. _cameraTransformMatrix: Matrix;
  8473. /** @hidden */
  8474. _cameraRotationMatrix: Matrix;
  8475. /** @hidden */
  8476. _referencePoint: Vector3;
  8477. /** @hidden */
  8478. _transformedReferencePoint: Vector3;
  8479. protected _globalCurrentTarget: Vector3;
  8480. protected _globalCurrentUpVector: Vector3;
  8481. /** @hidden */
  8482. _reset: () => void;
  8483. private _defaultUp;
  8484. /**
  8485. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8486. * This is the base of the follow, arc rotate cameras and Free camera
  8487. * @see http://doc.babylonjs.com/features/cameras
  8488. * @param name Defines the name of the camera in the scene
  8489. * @param position Defines the start position of the camera in the scene
  8490. * @param scene Defines the scene the camera belongs to
  8491. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8492. */
  8493. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8494. /**
  8495. * Gets the position in front of the camera at a given distance.
  8496. * @param distance The distance from the camera we want the position to be
  8497. * @returns the position
  8498. */
  8499. getFrontPosition(distance: number): Vector3;
  8500. /** @hidden */
  8501. _getLockedTargetPosition(): Nullable<Vector3>;
  8502. private _storedPosition;
  8503. private _storedRotation;
  8504. private _storedRotationQuaternion;
  8505. /**
  8506. * Store current camera state of the camera (fov, position, rotation, etc..)
  8507. * @returns the camera
  8508. */
  8509. storeState(): Camera;
  8510. /**
  8511. * Restored camera state. You must call storeState() first
  8512. * @returns whether it was successful or not
  8513. * @hidden
  8514. */
  8515. _restoreStateValues(): boolean;
  8516. /** @hidden */
  8517. _initCache(): void;
  8518. /** @hidden */
  8519. _updateCache(ignoreParentClass?: boolean): void;
  8520. /** @hidden */
  8521. _isSynchronizedViewMatrix(): boolean;
  8522. /** @hidden */
  8523. _computeLocalCameraSpeed(): number;
  8524. /**
  8525. * Defines the target the camera should look at.
  8526. * @param target Defines the new target as a Vector or a mesh
  8527. */
  8528. setTarget(target: Vector3): void;
  8529. /**
  8530. * Return the current target position of the camera. This value is expressed in local space.
  8531. * @returns the target position
  8532. */
  8533. getTarget(): Vector3;
  8534. /** @hidden */
  8535. _decideIfNeedsToMove(): boolean;
  8536. /** @hidden */
  8537. _updatePosition(): void;
  8538. /** @hidden */
  8539. _checkInputs(): void;
  8540. protected _updateCameraRotationMatrix(): void;
  8541. /**
  8542. * 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)
  8543. * @returns the current camera
  8544. */
  8545. private _rotateUpVectorWithCameraRotationMatrix;
  8546. private _cachedRotationZ;
  8547. private _cachedQuaternionRotationZ;
  8548. /** @hidden */
  8549. _getViewMatrix(): Matrix;
  8550. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8551. /**
  8552. * @hidden
  8553. */
  8554. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8555. /**
  8556. * @hidden
  8557. */
  8558. _updateRigCameras(): void;
  8559. private _getRigCamPositionAndTarget;
  8560. /**
  8561. * Gets the current object class name.
  8562. * @return the class name
  8563. */
  8564. getClassName(): string;
  8565. }
  8566. }
  8567. declare module BABYLON {
  8568. /**
  8569. * Gather the list of keyboard event types as constants.
  8570. */
  8571. export class KeyboardEventTypes {
  8572. /**
  8573. * The keydown event is fired when a key becomes active (pressed).
  8574. */
  8575. static readonly KEYDOWN: number;
  8576. /**
  8577. * The keyup event is fired when a key has been released.
  8578. */
  8579. static readonly KEYUP: number;
  8580. }
  8581. /**
  8582. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8583. */
  8584. export class KeyboardInfo {
  8585. /**
  8586. * Defines the type of event (KeyboardEventTypes)
  8587. */
  8588. type: number;
  8589. /**
  8590. * Defines the related dom event
  8591. */
  8592. event: KeyboardEvent;
  8593. /**
  8594. * Instantiates a new keyboard info.
  8595. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8596. * @param type Defines the type of event (KeyboardEventTypes)
  8597. * @param event Defines the related dom event
  8598. */
  8599. constructor(
  8600. /**
  8601. * Defines the type of event (KeyboardEventTypes)
  8602. */
  8603. type: number,
  8604. /**
  8605. * Defines the related dom event
  8606. */
  8607. event: KeyboardEvent);
  8608. }
  8609. /**
  8610. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8611. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8612. */
  8613. export class KeyboardInfoPre extends KeyboardInfo {
  8614. /**
  8615. * Defines the type of event (KeyboardEventTypes)
  8616. */
  8617. type: number;
  8618. /**
  8619. * Defines the related dom event
  8620. */
  8621. event: KeyboardEvent;
  8622. /**
  8623. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8624. */
  8625. skipOnPointerObservable: boolean;
  8626. /**
  8627. * Instantiates a new keyboard pre info.
  8628. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8629. * @param type Defines the type of event (KeyboardEventTypes)
  8630. * @param event Defines the related dom event
  8631. */
  8632. constructor(
  8633. /**
  8634. * Defines the type of event (KeyboardEventTypes)
  8635. */
  8636. type: number,
  8637. /**
  8638. * Defines the related dom event
  8639. */
  8640. event: KeyboardEvent);
  8641. }
  8642. }
  8643. declare module BABYLON {
  8644. /**
  8645. * Manage the keyboard inputs to control the movement of a free camera.
  8646. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8647. */
  8648. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8649. /**
  8650. * Defines the camera the input is attached to.
  8651. */
  8652. camera: FreeCamera;
  8653. /**
  8654. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8655. */
  8656. keysUp: number[];
  8657. /**
  8658. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8659. */
  8660. keysDown: number[];
  8661. /**
  8662. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8663. */
  8664. keysLeft: number[];
  8665. /**
  8666. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8667. */
  8668. keysRight: number[];
  8669. private _keys;
  8670. private _onCanvasBlurObserver;
  8671. private _onKeyboardObserver;
  8672. private _engine;
  8673. private _scene;
  8674. /**
  8675. * Attach the input controls to a specific dom element to get the input from.
  8676. * @param element Defines the element the controls should be listened from
  8677. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8678. */
  8679. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8680. /**
  8681. * Detach the current controls from the specified dom element.
  8682. * @param element Defines the element to stop listening the inputs from
  8683. */
  8684. detachControl(element: Nullable<HTMLElement>): void;
  8685. /**
  8686. * Update the current camera state depending on the inputs that have been used this frame.
  8687. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8688. */
  8689. checkInputs(): void;
  8690. /**
  8691. * Gets the class name of the current intput.
  8692. * @returns the class name
  8693. */
  8694. getClassName(): string;
  8695. /** @hidden */
  8696. _onLostFocus(): void;
  8697. /**
  8698. * Get the friendly name associated with the input class.
  8699. * @returns the input friendly name
  8700. */
  8701. getSimpleName(): string;
  8702. }
  8703. }
  8704. declare module BABYLON {
  8705. /**
  8706. * Interface describing all the common properties and methods a shadow light needs to implement.
  8707. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8708. * as well as binding the different shadow properties to the effects.
  8709. */
  8710. export interface IShadowLight extends Light {
  8711. /**
  8712. * The light id in the scene (used in scene.findLighById for instance)
  8713. */
  8714. id: string;
  8715. /**
  8716. * The position the shdow will be casted from.
  8717. */
  8718. position: Vector3;
  8719. /**
  8720. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8721. */
  8722. direction: Vector3;
  8723. /**
  8724. * The transformed position. Position of the light in world space taking parenting in account.
  8725. */
  8726. transformedPosition: Vector3;
  8727. /**
  8728. * The transformed direction. Direction of the light in world space taking parenting in account.
  8729. */
  8730. transformedDirection: Vector3;
  8731. /**
  8732. * The friendly name of the light in the scene.
  8733. */
  8734. name: string;
  8735. /**
  8736. * Defines the shadow projection clipping minimum z value.
  8737. */
  8738. shadowMinZ: number;
  8739. /**
  8740. * Defines the shadow projection clipping maximum z value.
  8741. */
  8742. shadowMaxZ: number;
  8743. /**
  8744. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8745. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8746. */
  8747. computeTransformedInformation(): boolean;
  8748. /**
  8749. * Gets the scene the light belongs to.
  8750. * @returns The scene
  8751. */
  8752. getScene(): Scene;
  8753. /**
  8754. * Callback defining a custom Projection Matrix Builder.
  8755. * This can be used to override the default projection matrix computation.
  8756. */
  8757. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8758. /**
  8759. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8760. * @param matrix The materix to updated with the projection information
  8761. * @param viewMatrix The transform matrix of the light
  8762. * @param renderList The list of mesh to render in the map
  8763. * @returns The current light
  8764. */
  8765. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8766. /**
  8767. * Gets the current depth scale used in ESM.
  8768. * @returns The scale
  8769. */
  8770. getDepthScale(): number;
  8771. /**
  8772. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8773. * @returns true if a cube texture needs to be use
  8774. */
  8775. needCube(): boolean;
  8776. /**
  8777. * Detects if the projection matrix requires to be recomputed this frame.
  8778. * @returns true if it requires to be recomputed otherwise, false.
  8779. */
  8780. needProjectionMatrixCompute(): boolean;
  8781. /**
  8782. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8783. */
  8784. forceProjectionMatrixCompute(): void;
  8785. /**
  8786. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8787. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8788. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8789. */
  8790. getShadowDirection(faceIndex?: number): Vector3;
  8791. /**
  8792. * Gets the minZ used for shadow according to both the scene and the light.
  8793. * @param activeCamera The camera we are returning the min for
  8794. * @returns the depth min z
  8795. */
  8796. getDepthMinZ(activeCamera: Camera): number;
  8797. /**
  8798. * Gets the maxZ used for shadow according to both the scene and the light.
  8799. * @param activeCamera The camera we are returning the max for
  8800. * @returns the depth max z
  8801. */
  8802. getDepthMaxZ(activeCamera: Camera): number;
  8803. }
  8804. /**
  8805. * Base implementation IShadowLight
  8806. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8807. */
  8808. export abstract class ShadowLight extends Light implements IShadowLight {
  8809. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8810. protected _position: Vector3;
  8811. protected _setPosition(value: Vector3): void;
  8812. /**
  8813. * Sets the position the shadow will be casted from. Also use as the light position for both
  8814. * point and spot lights.
  8815. */
  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. position: Vector3;
  8821. protected _direction: Vector3;
  8822. protected _setDirection(value: Vector3): void;
  8823. /**
  8824. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8825. * Also use as the light direction on spot and directional lights.
  8826. */
  8827. /**
  8828. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8829. * Also use as the light direction on spot and directional lights.
  8830. */
  8831. direction: Vector3;
  8832. private _shadowMinZ;
  8833. /**
  8834. * Gets the shadow projection clipping minimum z value.
  8835. */
  8836. /**
  8837. * Sets the shadow projection clipping minimum z value.
  8838. */
  8839. shadowMinZ: number;
  8840. private _shadowMaxZ;
  8841. /**
  8842. * Sets the shadow projection clipping maximum z value.
  8843. */
  8844. /**
  8845. * Gets the shadow projection clipping maximum z value.
  8846. */
  8847. shadowMaxZ: number;
  8848. /**
  8849. * Callback defining a custom Projection Matrix Builder.
  8850. * This can be used to override the default projection matrix computation.
  8851. */
  8852. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8853. /**
  8854. * The transformed position. Position of the light in world space taking parenting in account.
  8855. */
  8856. transformedPosition: Vector3;
  8857. /**
  8858. * The transformed direction. Direction of the light in world space taking parenting in account.
  8859. */
  8860. transformedDirection: Vector3;
  8861. private _needProjectionMatrixCompute;
  8862. /**
  8863. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8864. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8865. */
  8866. computeTransformedInformation(): boolean;
  8867. /**
  8868. * Return the depth scale used for the shadow map.
  8869. * @returns the depth scale.
  8870. */
  8871. getDepthScale(): number;
  8872. /**
  8873. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8874. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8875. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8876. */
  8877. getShadowDirection(faceIndex?: number): Vector3;
  8878. /**
  8879. * Returns the ShadowLight absolute position in the World.
  8880. * @returns the position vector in world space
  8881. */
  8882. getAbsolutePosition(): Vector3;
  8883. /**
  8884. * Sets the ShadowLight direction toward the passed target.
  8885. * @param target The point to target in local space
  8886. * @returns the updated ShadowLight direction
  8887. */
  8888. setDirectionToTarget(target: Vector3): Vector3;
  8889. /**
  8890. * Returns the light rotation in euler definition.
  8891. * @returns the x y z rotation in local space.
  8892. */
  8893. getRotation(): Vector3;
  8894. /**
  8895. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8896. * @returns true if a cube texture needs to be use
  8897. */
  8898. needCube(): boolean;
  8899. /**
  8900. * Detects if the projection matrix requires to be recomputed this frame.
  8901. * @returns true if it requires to be recomputed otherwise, false.
  8902. */
  8903. needProjectionMatrixCompute(): boolean;
  8904. /**
  8905. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8906. */
  8907. forceProjectionMatrixCompute(): void;
  8908. /** @hidden */
  8909. _initCache(): void;
  8910. /** @hidden */
  8911. _isSynchronized(): boolean;
  8912. /**
  8913. * Computes the world matrix of the node
  8914. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8915. * @returns the world matrix
  8916. */
  8917. computeWorldMatrix(force?: boolean): Matrix;
  8918. /**
  8919. * Gets the minZ used for shadow according to both the scene and the light.
  8920. * @param activeCamera The camera we are returning the min for
  8921. * @returns the depth min z
  8922. */
  8923. getDepthMinZ(activeCamera: Camera): number;
  8924. /**
  8925. * Gets the maxZ used for shadow according to both the scene and the light.
  8926. * @param activeCamera The camera we are returning the max for
  8927. * @returns the depth max z
  8928. */
  8929. getDepthMaxZ(activeCamera: Camera): number;
  8930. /**
  8931. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8932. * @param matrix The materix to updated with the projection information
  8933. * @param viewMatrix The transform matrix of the light
  8934. * @param renderList The list of mesh to render in the map
  8935. * @returns The current light
  8936. */
  8937. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8938. }
  8939. }
  8940. declare module BABYLON {
  8941. /**
  8942. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8943. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8944. */
  8945. export class EffectFallbacks implements IEffectFallbacks {
  8946. private _defines;
  8947. private _currentRank;
  8948. private _maxRank;
  8949. private _mesh;
  8950. /**
  8951. * Removes the fallback from the bound mesh.
  8952. */
  8953. unBindMesh(): void;
  8954. /**
  8955. * Adds a fallback on the specified property.
  8956. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8957. * @param define The name of the define in the shader
  8958. */
  8959. addFallback(rank: number, define: string): void;
  8960. /**
  8961. * Sets the mesh to use CPU skinning when needing to fallback.
  8962. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8963. * @param mesh The mesh to use the fallbacks.
  8964. */
  8965. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8966. /**
  8967. * Checks to see if more fallbacks are still availible.
  8968. */
  8969. readonly hasMoreFallbacks: boolean;
  8970. /**
  8971. * Removes the defines that should be removed when falling back.
  8972. * @param currentDefines defines the current define statements for the shader.
  8973. * @param effect defines the current effect we try to compile
  8974. * @returns The resulting defines with defines of the current rank removed.
  8975. */
  8976. reduce(currentDefines: string, effect: Effect): string;
  8977. }
  8978. }
  8979. declare module BABYLON {
  8980. /**
  8981. * "Static Class" containing the most commonly used helper while dealing with material for
  8982. * rendering purpose.
  8983. *
  8984. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8985. *
  8986. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8987. */
  8988. export class MaterialHelper {
  8989. /**
  8990. * Bind the current view position to an effect.
  8991. * @param effect The effect to be bound
  8992. * @param scene The scene the eyes position is used from
  8993. */
  8994. static BindEyePosition(effect: Effect, scene: Scene): void;
  8995. /**
  8996. * Helps preparing the defines values about the UVs in used in the effect.
  8997. * UVs are shared as much as we can accross channels in the shaders.
  8998. * @param texture The texture we are preparing the UVs for
  8999. * @param defines The defines to update
  9000. * @param key The channel key "diffuse", "specular"... used in the shader
  9001. */
  9002. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9003. /**
  9004. * Binds a texture matrix value to its corrsponding uniform
  9005. * @param texture The texture to bind the matrix for
  9006. * @param uniformBuffer The uniform buffer receivin the data
  9007. * @param key The channel key "diffuse", "specular"... used in the shader
  9008. */
  9009. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9010. /**
  9011. * Gets the current status of the fog (should it be enabled?)
  9012. * @param mesh defines the mesh to evaluate for fog support
  9013. * @param scene defines the hosting scene
  9014. * @returns true if fog must be enabled
  9015. */
  9016. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9017. /**
  9018. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9019. * @param mesh defines the current mesh
  9020. * @param scene defines the current scene
  9021. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9022. * @param pointsCloud defines if point cloud rendering has to be turned on
  9023. * @param fogEnabled defines if fog has to be turned on
  9024. * @param alphaTest defines if alpha testing has to be turned on
  9025. * @param defines defines the current list of defines
  9026. */
  9027. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9028. /**
  9029. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9030. * @param scene defines the current scene
  9031. * @param engine defines the current engine
  9032. * @param defines specifies the list of active defines
  9033. * @param useInstances defines if instances have to be turned on
  9034. * @param useClipPlane defines if clip plane have to be turned on
  9035. */
  9036. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9037. /**
  9038. * Prepares the defines for bones
  9039. * @param mesh The mesh containing the geometry data we will draw
  9040. * @param defines The defines to update
  9041. */
  9042. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9043. /**
  9044. * Prepares the defines for morph targets
  9045. * @param mesh The mesh containing the geometry data we will draw
  9046. * @param defines The defines to update
  9047. */
  9048. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9049. /**
  9050. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9051. * @param mesh The mesh containing the geometry data we will draw
  9052. * @param defines The defines to update
  9053. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9054. * @param useBones Precise whether bones should be used or not (override mesh info)
  9055. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9056. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9057. * @returns false if defines are considered not dirty and have not been checked
  9058. */
  9059. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9060. /**
  9061. * Prepares the defines related to multiview
  9062. * @param scene The scene we are intending to draw
  9063. * @param defines The defines to update
  9064. */
  9065. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9066. /**
  9067. * Prepares the defines related to the light information passed in parameter
  9068. * @param scene The scene we are intending to draw
  9069. * @param mesh The mesh the effect is compiling for
  9070. * @param light The light the effect is compiling for
  9071. * @param lightIndex The index of the light
  9072. * @param defines The defines to update
  9073. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9074. * @param state Defines the current state regarding what is needed (normals, etc...)
  9075. */
  9076. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9077. needNormals: boolean;
  9078. needRebuild: boolean;
  9079. shadowEnabled: boolean;
  9080. specularEnabled: boolean;
  9081. lightmapMode: boolean;
  9082. }): void;
  9083. /**
  9084. * Prepares the defines related to the light information passed in parameter
  9085. * @param scene The scene we are intending to draw
  9086. * @param mesh The mesh the effect is compiling for
  9087. * @param defines The defines to update
  9088. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9089. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9090. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9091. * @returns true if normals will be required for the rest of the effect
  9092. */
  9093. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9094. /**
  9095. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9096. * @param lightIndex defines the light index
  9097. * @param uniformsList The uniform list
  9098. * @param samplersList The sampler list
  9099. * @param projectedLightTexture defines if projected texture must be used
  9100. * @param uniformBuffersList defines an optional list of uniform buffers
  9101. */
  9102. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9103. /**
  9104. * Prepares the uniforms and samplers list to be used in the effect
  9105. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9106. * @param samplersList The sampler list
  9107. * @param defines The defines helping in the list generation
  9108. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9109. */
  9110. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9111. /**
  9112. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9113. * @param defines The defines to update while falling back
  9114. * @param fallbacks The authorized effect fallbacks
  9115. * @param maxSimultaneousLights The maximum number of lights allowed
  9116. * @param rank the current rank of the Effect
  9117. * @returns The newly affected rank
  9118. */
  9119. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9120. private static _TmpMorphInfluencers;
  9121. /**
  9122. * Prepares the list of attributes required for morph targets according to the effect defines.
  9123. * @param attribs The current list of supported attribs
  9124. * @param mesh The mesh to prepare the morph targets attributes for
  9125. * @param influencers The number of influencers
  9126. */
  9127. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9128. /**
  9129. * Prepares the list of attributes required for morph targets according to the effect defines.
  9130. * @param attribs The current list of supported attribs
  9131. * @param mesh The mesh to prepare the morph targets attributes for
  9132. * @param defines The current Defines of the effect
  9133. */
  9134. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9135. /**
  9136. * Prepares the list of attributes required for bones according to the effect defines.
  9137. * @param attribs The current list of supported attribs
  9138. * @param mesh The mesh to prepare the bones attributes for
  9139. * @param defines The current Defines of the effect
  9140. * @param fallbacks The current efffect fallback strategy
  9141. */
  9142. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9143. /**
  9144. * Check and prepare the list of attributes required for instances according to the effect defines.
  9145. * @param attribs The current list of supported attribs
  9146. * @param defines The current MaterialDefines of the effect
  9147. */
  9148. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9149. /**
  9150. * Add the list of attributes required for instances to the attribs array.
  9151. * @param attribs The current list of supported attribs
  9152. */
  9153. static PushAttributesForInstances(attribs: string[]): void;
  9154. /**
  9155. * Binds the light information to the effect.
  9156. * @param light The light containing the generator
  9157. * @param effect The effect we are binding the data to
  9158. * @param lightIndex The light index in the effect used to render
  9159. */
  9160. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9161. /**
  9162. * Binds the lights information from the scene to the effect for the given mesh.
  9163. * @param light Light to bind
  9164. * @param lightIndex Light index
  9165. * @param scene The scene where the light belongs to
  9166. * @param effect The effect we are binding the data to
  9167. * @param useSpecular Defines if specular is supported
  9168. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9169. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9170. */
  9171. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9172. /**
  9173. * Binds the lights information from the scene to the effect for the given mesh.
  9174. * @param scene The scene the lights belongs to
  9175. * @param mesh The mesh we are binding the information to render
  9176. * @param effect The effect we are binding the data to
  9177. * @param defines The generated defines for the effect
  9178. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9179. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9180. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9181. */
  9182. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9183. private static _tempFogColor;
  9184. /**
  9185. * Binds the fog information from the scene to the effect for the given mesh.
  9186. * @param scene The scene the lights belongs to
  9187. * @param mesh The mesh we are binding the information to render
  9188. * @param effect The effect we are binding the data to
  9189. * @param linearSpace Defines if the fog effect is applied in linear space
  9190. */
  9191. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9192. /**
  9193. * Binds the bones information from the mesh to the effect.
  9194. * @param mesh The mesh we are binding the information to render
  9195. * @param effect The effect we are binding the data to
  9196. */
  9197. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9198. /**
  9199. * Binds the morph targets information from the mesh to the effect.
  9200. * @param abstractMesh The mesh we are binding the information to render
  9201. * @param effect The effect we are binding the data to
  9202. */
  9203. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9204. /**
  9205. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9206. * @param defines The generated defines used in the effect
  9207. * @param effect The effect we are binding the data to
  9208. * @param scene The scene we are willing to render with logarithmic scale for
  9209. */
  9210. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9211. /**
  9212. * Binds the clip plane information from the scene to the effect.
  9213. * @param scene The scene the clip plane information are extracted from
  9214. * @param effect The effect we are binding the data to
  9215. */
  9216. static BindClipPlane(effect: Effect, scene: Scene): void;
  9217. }
  9218. }
  9219. declare module BABYLON {
  9220. /** @hidden */
  9221. export var packingFunctions: {
  9222. name: string;
  9223. shader: string;
  9224. };
  9225. }
  9226. declare module BABYLON {
  9227. /** @hidden */
  9228. export var shadowMapPixelShader: {
  9229. name: string;
  9230. shader: string;
  9231. };
  9232. }
  9233. declare module BABYLON {
  9234. /** @hidden */
  9235. export var bonesDeclaration: {
  9236. name: string;
  9237. shader: string;
  9238. };
  9239. }
  9240. declare module BABYLON {
  9241. /** @hidden */
  9242. export var morphTargetsVertexGlobalDeclaration: {
  9243. name: string;
  9244. shader: string;
  9245. };
  9246. }
  9247. declare module BABYLON {
  9248. /** @hidden */
  9249. export var morphTargetsVertexDeclaration: {
  9250. name: string;
  9251. shader: string;
  9252. };
  9253. }
  9254. declare module BABYLON {
  9255. /** @hidden */
  9256. export var instancesDeclaration: {
  9257. name: string;
  9258. shader: string;
  9259. };
  9260. }
  9261. declare module BABYLON {
  9262. /** @hidden */
  9263. export var helperFunctions: {
  9264. name: string;
  9265. shader: string;
  9266. };
  9267. }
  9268. declare module BABYLON {
  9269. /** @hidden */
  9270. export var morphTargetsVertex: {
  9271. name: string;
  9272. shader: string;
  9273. };
  9274. }
  9275. declare module BABYLON {
  9276. /** @hidden */
  9277. export var instancesVertex: {
  9278. name: string;
  9279. shader: string;
  9280. };
  9281. }
  9282. declare module BABYLON {
  9283. /** @hidden */
  9284. export var bonesVertex: {
  9285. name: string;
  9286. shader: string;
  9287. };
  9288. }
  9289. declare module BABYLON {
  9290. /** @hidden */
  9291. export var shadowMapVertexShader: {
  9292. name: string;
  9293. shader: string;
  9294. };
  9295. }
  9296. declare module BABYLON {
  9297. /** @hidden */
  9298. export var depthBoxBlurPixelShader: {
  9299. name: string;
  9300. shader: string;
  9301. };
  9302. }
  9303. declare module BABYLON {
  9304. /**
  9305. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9306. */
  9307. export interface ICustomShaderOptions {
  9308. /**
  9309. * Gets or sets the custom shader name to use
  9310. */
  9311. shaderName: string;
  9312. /**
  9313. * The list of attribute names used in the shader
  9314. */
  9315. attributes?: string[];
  9316. /**
  9317. * The list of unifrom names used in the shader
  9318. */
  9319. uniforms?: string[];
  9320. /**
  9321. * The list of sampler names used in the shader
  9322. */
  9323. samplers?: string[];
  9324. /**
  9325. * The list of defines used in the shader
  9326. */
  9327. defines?: string[];
  9328. }
  9329. /**
  9330. * Interface to implement to create a shadow generator compatible with BJS.
  9331. */
  9332. export interface IShadowGenerator {
  9333. /**
  9334. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9335. * @returns The render target texture if present otherwise, null
  9336. */
  9337. getShadowMap(): Nullable<RenderTargetTexture>;
  9338. /**
  9339. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9340. * @returns The render target texture if the shadow map is present otherwise, null
  9341. */
  9342. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9343. /**
  9344. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9345. * @param subMesh The submesh we want to render in the shadow map
  9346. * @param useInstances Defines wether will draw in the map using instances
  9347. * @returns true if ready otherwise, false
  9348. */
  9349. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9350. /**
  9351. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9352. * @param defines Defines of the material we want to update
  9353. * @param lightIndex Index of the light in the enabled light list of the material
  9354. */
  9355. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9356. /**
  9357. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9358. * defined in the generator but impacting the effect).
  9359. * It implies the unifroms available on the materials are the standard BJS ones.
  9360. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9361. * @param effect The effect we are binfing the information for
  9362. */
  9363. bindShadowLight(lightIndex: string, effect: Effect): void;
  9364. /**
  9365. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9366. * (eq to shadow prjection matrix * light transform matrix)
  9367. * @returns The transform matrix used to create the shadow map
  9368. */
  9369. getTransformMatrix(): Matrix;
  9370. /**
  9371. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9372. * Cube and 2D textures for instance.
  9373. */
  9374. recreateShadowMap(): void;
  9375. /**
  9376. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9377. * @param onCompiled Callback triggered at the and of the effects compilation
  9378. * @param options Sets of optional options forcing the compilation with different modes
  9379. */
  9380. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9381. useInstances: boolean;
  9382. }>): void;
  9383. /**
  9384. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9385. * @param options Sets of optional options forcing the compilation with different modes
  9386. * @returns A promise that resolves when the compilation completes
  9387. */
  9388. forceCompilationAsync(options?: Partial<{
  9389. useInstances: boolean;
  9390. }>): Promise<void>;
  9391. /**
  9392. * Serializes the shadow generator setup to a json object.
  9393. * @returns The serialized JSON object
  9394. */
  9395. serialize(): any;
  9396. /**
  9397. * Disposes the Shadow map and related Textures and effects.
  9398. */
  9399. dispose(): void;
  9400. }
  9401. /**
  9402. * Default implementation IShadowGenerator.
  9403. * This is the main object responsible of generating shadows in the framework.
  9404. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9405. */
  9406. export class ShadowGenerator implements IShadowGenerator {
  9407. /**
  9408. * Shadow generator mode None: no filtering applied.
  9409. */
  9410. static readonly FILTER_NONE: number;
  9411. /**
  9412. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9413. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9414. */
  9415. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9416. /**
  9417. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9418. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9419. */
  9420. static readonly FILTER_POISSONSAMPLING: number;
  9421. /**
  9422. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9423. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9424. */
  9425. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9426. /**
  9427. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9428. * edge artifacts on steep falloff.
  9429. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9430. */
  9431. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9432. /**
  9433. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9434. * edge artifacts on steep falloff.
  9435. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9436. */
  9437. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9438. /**
  9439. * Shadow generator mode PCF: Percentage Closer Filtering
  9440. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9441. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9442. */
  9443. static readonly FILTER_PCF: number;
  9444. /**
  9445. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9446. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9447. * Contact Hardening
  9448. */
  9449. static readonly FILTER_PCSS: number;
  9450. /**
  9451. * Reserved for PCF and PCSS
  9452. * Highest Quality.
  9453. *
  9454. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9455. *
  9456. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9457. */
  9458. static readonly QUALITY_HIGH: number;
  9459. /**
  9460. * Reserved for PCF and PCSS
  9461. * Good tradeoff for quality/perf cross devices
  9462. *
  9463. * Execute PCF on a 3*3 kernel.
  9464. *
  9465. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9466. */
  9467. static readonly QUALITY_MEDIUM: number;
  9468. /**
  9469. * Reserved for PCF and PCSS
  9470. * The lowest quality but the fastest.
  9471. *
  9472. * Execute PCF on a 1*1 kernel.
  9473. *
  9474. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9475. */
  9476. static readonly QUALITY_LOW: number;
  9477. /** Gets or sets the custom shader name to use */
  9478. customShaderOptions: ICustomShaderOptions;
  9479. /**
  9480. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9481. */
  9482. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9483. /**
  9484. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9485. */
  9486. onAfterShadowMapRenderObservable: Observable<Effect>;
  9487. /**
  9488. * Observable triggered before a mesh is rendered in the shadow map.
  9489. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9490. */
  9491. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9492. /**
  9493. * Observable triggered after a mesh is rendered in the shadow map.
  9494. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9495. */
  9496. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9497. private _bias;
  9498. /**
  9499. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9500. */
  9501. /**
  9502. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9503. */
  9504. bias: number;
  9505. private _normalBias;
  9506. /**
  9507. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9508. */
  9509. /**
  9510. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9511. */
  9512. normalBias: number;
  9513. private _blurBoxOffset;
  9514. /**
  9515. * Gets the blur box offset: offset applied during the blur pass.
  9516. * Only useful if useKernelBlur = false
  9517. */
  9518. /**
  9519. * Sets the blur box offset: offset applied during the blur pass.
  9520. * Only useful if useKernelBlur = false
  9521. */
  9522. blurBoxOffset: number;
  9523. private _blurScale;
  9524. /**
  9525. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9526. * 2 means half of the size.
  9527. */
  9528. /**
  9529. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9530. * 2 means half of the size.
  9531. */
  9532. blurScale: number;
  9533. private _blurKernel;
  9534. /**
  9535. * Gets the blur kernel: kernel size of the blur pass.
  9536. * Only useful if useKernelBlur = true
  9537. */
  9538. /**
  9539. * Sets the blur kernel: kernel size of the blur pass.
  9540. * Only useful if useKernelBlur = true
  9541. */
  9542. blurKernel: number;
  9543. private _useKernelBlur;
  9544. /**
  9545. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9546. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9547. */
  9548. /**
  9549. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9550. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9551. */
  9552. useKernelBlur: boolean;
  9553. private _depthScale;
  9554. /**
  9555. * Gets the depth scale used in ESM mode.
  9556. */
  9557. /**
  9558. * Sets the depth scale used in ESM mode.
  9559. * This can override the scale stored on the light.
  9560. */
  9561. depthScale: number;
  9562. private _filter;
  9563. /**
  9564. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9565. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9566. */
  9567. /**
  9568. * Sets 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. filter: number;
  9572. /**
  9573. * Gets if the current filter is set to Poisson Sampling.
  9574. */
  9575. /**
  9576. * Sets the current filter to Poisson Sampling.
  9577. */
  9578. usePoissonSampling: boolean;
  9579. /**
  9580. * Gets if the current filter is set to ESM.
  9581. */
  9582. /**
  9583. * Sets the current filter is to ESM.
  9584. */
  9585. useExponentialShadowMap: boolean;
  9586. /**
  9587. * Gets if the current filter is set to filtered ESM.
  9588. */
  9589. /**
  9590. * Gets if the current filter is set to filtered ESM.
  9591. */
  9592. useBlurExponentialShadowMap: boolean;
  9593. /**
  9594. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9595. * exponential to prevent steep falloff artifacts).
  9596. */
  9597. /**
  9598. * Sets the current filter to "close ESM" (using the inverse of the
  9599. * exponential to prevent steep falloff artifacts).
  9600. */
  9601. useCloseExponentialShadowMap: boolean;
  9602. /**
  9603. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9604. * exponential to prevent steep falloff artifacts).
  9605. */
  9606. /**
  9607. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9608. * exponential to prevent steep falloff artifacts).
  9609. */
  9610. useBlurCloseExponentialShadowMap: boolean;
  9611. /**
  9612. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9613. */
  9614. /**
  9615. * Sets the current filter to "PCF" (percentage closer filtering).
  9616. */
  9617. usePercentageCloserFiltering: boolean;
  9618. private _filteringQuality;
  9619. /**
  9620. * Gets the PCF or PCSS Quality.
  9621. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9622. */
  9623. /**
  9624. * Sets the PCF or PCSS Quality.
  9625. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9626. */
  9627. filteringQuality: number;
  9628. /**
  9629. * Gets if the current filter is set to "PCSS" (contact hardening).
  9630. */
  9631. /**
  9632. * Sets the current filter to "PCSS" (contact hardening).
  9633. */
  9634. useContactHardeningShadow: boolean;
  9635. private _contactHardeningLightSizeUVRatio;
  9636. /**
  9637. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9638. * Using a ratio helps keeping shape stability independently of the map size.
  9639. *
  9640. * It does not account for the light projection as it was having too much
  9641. * instability during the light setup or during light position changes.
  9642. *
  9643. * Only valid if useContactHardeningShadow is true.
  9644. */
  9645. /**
  9646. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9647. * Using a ratio helps keeping shape stability independently of the map size.
  9648. *
  9649. * It does not account for the light projection as it was having too much
  9650. * instability during the light setup or during light position changes.
  9651. *
  9652. * Only valid if useContactHardeningShadow is true.
  9653. */
  9654. contactHardeningLightSizeUVRatio: number;
  9655. private _darkness;
  9656. /** Gets or sets the actual darkness of a shadow */
  9657. darkness: number;
  9658. /**
  9659. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9660. * 0 means strongest and 1 would means no shadow.
  9661. * @returns the darkness.
  9662. */
  9663. getDarkness(): number;
  9664. /**
  9665. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9666. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9667. * @returns the shadow generator allowing fluent coding.
  9668. */
  9669. setDarkness(darkness: number): ShadowGenerator;
  9670. private _transparencyShadow;
  9671. /** Gets or sets the ability to have transparent shadow */
  9672. transparencyShadow: boolean;
  9673. /**
  9674. * Sets the ability to have transparent shadow (boolean).
  9675. * @param transparent True if transparent else False
  9676. * @returns the shadow generator allowing fluent coding
  9677. */
  9678. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9679. private _shadowMap;
  9680. private _shadowMap2;
  9681. /**
  9682. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9683. * @returns The render target texture if present otherwise, null
  9684. */
  9685. getShadowMap(): Nullable<RenderTargetTexture>;
  9686. /**
  9687. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9688. * @returns The render target texture if the shadow map is present otherwise, null
  9689. */
  9690. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9691. /**
  9692. * Gets the class name of that object
  9693. * @returns "ShadowGenerator"
  9694. */
  9695. getClassName(): string;
  9696. /**
  9697. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9698. * @param mesh Mesh to add
  9699. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9700. * @returns the Shadow Generator itself
  9701. */
  9702. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9703. /**
  9704. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9705. * @param mesh Mesh to remove
  9706. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9707. * @returns the Shadow Generator itself
  9708. */
  9709. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9710. /**
  9711. * Controls the extent to which the shadows fade out at the edge of the frustum
  9712. * Used only by directionals and spots
  9713. */
  9714. frustumEdgeFalloff: number;
  9715. private _light;
  9716. /**
  9717. * Returns the associated light object.
  9718. * @returns the light generating the shadow
  9719. */
  9720. getLight(): IShadowLight;
  9721. /**
  9722. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9723. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9724. * It might on the other hand introduce peter panning.
  9725. */
  9726. forceBackFacesOnly: boolean;
  9727. private _scene;
  9728. private _lightDirection;
  9729. private _effect;
  9730. private _viewMatrix;
  9731. private _projectionMatrix;
  9732. private _transformMatrix;
  9733. private _cachedPosition;
  9734. private _cachedDirection;
  9735. private _cachedDefines;
  9736. private _currentRenderID;
  9737. private _boxBlurPostprocess;
  9738. private _kernelBlurXPostprocess;
  9739. private _kernelBlurYPostprocess;
  9740. private _blurPostProcesses;
  9741. private _mapSize;
  9742. private _currentFaceIndex;
  9743. private _currentFaceIndexCache;
  9744. private _textureType;
  9745. private _defaultTextureMatrix;
  9746. private _storedUniqueId;
  9747. /** @hidden */
  9748. static _SceneComponentInitialization: (scene: Scene) => void;
  9749. /**
  9750. * Creates a ShadowGenerator object.
  9751. * A ShadowGenerator is the required tool to use the shadows.
  9752. * Each light casting shadows needs to use its own ShadowGenerator.
  9753. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9754. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9755. * @param light The light object generating the shadows.
  9756. * @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.
  9757. */
  9758. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9759. private _initializeGenerator;
  9760. private _initializeShadowMap;
  9761. private _initializeBlurRTTAndPostProcesses;
  9762. private _renderForShadowMap;
  9763. private _renderSubMeshForShadowMap;
  9764. private _applyFilterValues;
  9765. /**
  9766. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9767. * @param onCompiled Callback triggered at the and of the effects compilation
  9768. * @param options Sets of optional options forcing the compilation with different modes
  9769. */
  9770. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9771. useInstances: boolean;
  9772. }>): void;
  9773. /**
  9774. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9775. * @param options Sets of optional options forcing the compilation with different modes
  9776. * @returns A promise that resolves when the compilation completes
  9777. */
  9778. forceCompilationAsync(options?: Partial<{
  9779. useInstances: boolean;
  9780. }>): Promise<void>;
  9781. /**
  9782. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9783. * @param subMesh The submesh we want to render in the shadow map
  9784. * @param useInstances Defines wether will draw in the map using instances
  9785. * @returns true if ready otherwise, false
  9786. */
  9787. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9788. /**
  9789. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9790. * @param defines Defines of the material we want to update
  9791. * @param lightIndex Index of the light in the enabled light list of the material
  9792. */
  9793. prepareDefines(defines: any, lightIndex: number): void;
  9794. /**
  9795. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9796. * defined in the generator but impacting the effect).
  9797. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9798. * @param effect The effect we are binfing the information for
  9799. */
  9800. bindShadowLight(lightIndex: string, effect: Effect): void;
  9801. /**
  9802. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9803. * (eq to shadow prjection matrix * light transform matrix)
  9804. * @returns The transform matrix used to create the shadow map
  9805. */
  9806. getTransformMatrix(): Matrix;
  9807. /**
  9808. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9809. * Cube and 2D textures for instance.
  9810. */
  9811. recreateShadowMap(): void;
  9812. private _disposeBlurPostProcesses;
  9813. private _disposeRTTandPostProcesses;
  9814. /**
  9815. * Disposes the ShadowGenerator.
  9816. * Returns nothing.
  9817. */
  9818. dispose(): void;
  9819. /**
  9820. * Serializes the shadow generator setup to a json object.
  9821. * @returns The serialized JSON object
  9822. */
  9823. serialize(): any;
  9824. /**
  9825. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9826. * @param parsedShadowGenerator The JSON object to parse
  9827. * @param scene The scene to create the shadow map for
  9828. * @returns The parsed shadow generator
  9829. */
  9830. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9831. }
  9832. }
  9833. declare module BABYLON {
  9834. /**
  9835. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9836. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9837. * 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.
  9838. */
  9839. export abstract class Light extends Node {
  9840. /**
  9841. * Falloff Default: light is falling off following the material specification:
  9842. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9843. */
  9844. static readonly FALLOFF_DEFAULT: number;
  9845. /**
  9846. * Falloff Physical: light is falling off following the inverse squared distance law.
  9847. */
  9848. static readonly FALLOFF_PHYSICAL: number;
  9849. /**
  9850. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9851. * to enhance interoperability with other engines.
  9852. */
  9853. static readonly FALLOFF_GLTF: number;
  9854. /**
  9855. * Falloff Standard: light is falling off like in the standard material
  9856. * to enhance interoperability with other materials.
  9857. */
  9858. static readonly FALLOFF_STANDARD: number;
  9859. /**
  9860. * If every light affecting the material is in this lightmapMode,
  9861. * material.lightmapTexture adds or multiplies
  9862. * (depends on material.useLightmapAsShadowmap)
  9863. * after every other light calculations.
  9864. */
  9865. static readonly LIGHTMAP_DEFAULT: number;
  9866. /**
  9867. * material.lightmapTexture as only diffuse lighting from this light
  9868. * adds only specular lighting from this light
  9869. * adds dynamic shadows
  9870. */
  9871. static readonly LIGHTMAP_SPECULAR: number;
  9872. /**
  9873. * material.lightmapTexture as only lighting
  9874. * no light calculation from this light
  9875. * only adds dynamic shadows from this light
  9876. */
  9877. static readonly LIGHTMAP_SHADOWSONLY: number;
  9878. /**
  9879. * Each light type uses the default quantity according to its type:
  9880. * point/spot lights use luminous intensity
  9881. * directional lights use illuminance
  9882. */
  9883. static readonly INTENSITYMODE_AUTOMATIC: number;
  9884. /**
  9885. * lumen (lm)
  9886. */
  9887. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9888. /**
  9889. * candela (lm/sr)
  9890. */
  9891. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9892. /**
  9893. * lux (lm/m^2)
  9894. */
  9895. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9896. /**
  9897. * nit (cd/m^2)
  9898. */
  9899. static readonly INTENSITYMODE_LUMINANCE: number;
  9900. /**
  9901. * Light type const id of the point light.
  9902. */
  9903. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9904. /**
  9905. * Light type const id of the directional light.
  9906. */
  9907. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9908. /**
  9909. * Light type const id of the spot light.
  9910. */
  9911. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9912. /**
  9913. * Light type const id of the hemispheric light.
  9914. */
  9915. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9916. /**
  9917. * Diffuse gives the basic color to an object.
  9918. */
  9919. diffuse: Color3;
  9920. /**
  9921. * Specular produces a highlight color on an object.
  9922. * Note: This is note affecting PBR materials.
  9923. */
  9924. specular: Color3;
  9925. /**
  9926. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9927. * falling off base on range or angle.
  9928. * This can be set to any values in Light.FALLOFF_x.
  9929. *
  9930. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9931. * other types of materials.
  9932. */
  9933. falloffType: number;
  9934. /**
  9935. * Strength of the light.
  9936. * Note: By default it is define in the framework own unit.
  9937. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9938. */
  9939. intensity: number;
  9940. private _range;
  9941. protected _inverseSquaredRange: number;
  9942. /**
  9943. * Defines how far from the source the light is impacting in scene units.
  9944. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9945. */
  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. range: number;
  9951. /**
  9952. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9953. * of light.
  9954. */
  9955. private _photometricScale;
  9956. private _intensityMode;
  9957. /**
  9958. * Gets the photometric scale used to interpret the intensity.
  9959. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9960. */
  9961. /**
  9962. * Sets 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. intensityMode: number;
  9966. private _radius;
  9967. /**
  9968. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9969. */
  9970. /**
  9971. * sets the light radius used by PBR Materials to simulate soft area lights.
  9972. */
  9973. radius: number;
  9974. private _renderPriority;
  9975. /**
  9976. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9977. * exceeding the number allowed of the materials.
  9978. */
  9979. renderPriority: number;
  9980. private _shadowEnabled;
  9981. /**
  9982. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9983. * the current shadow generator.
  9984. */
  9985. /**
  9986. * Sets 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. shadowEnabled: boolean;
  9990. private _includedOnlyMeshes;
  9991. /**
  9992. * Gets the only meshes impacted by this light.
  9993. */
  9994. /**
  9995. * Sets the only meshes impacted by this light.
  9996. */
  9997. includedOnlyMeshes: AbstractMesh[];
  9998. private _excludedMeshes;
  9999. /**
  10000. * Gets the meshes not impacted by this light.
  10001. */
  10002. /**
  10003. * Sets the meshes not impacted by this light.
  10004. */
  10005. excludedMeshes: AbstractMesh[];
  10006. private _excludeWithLayerMask;
  10007. /**
  10008. * Gets the layer id use to find what meshes are not impacted by the light.
  10009. * Inactive if 0
  10010. */
  10011. /**
  10012. * Sets the layer id use to find what meshes are not impacted by the light.
  10013. * Inactive if 0
  10014. */
  10015. excludeWithLayerMask: number;
  10016. private _includeOnlyWithLayerMask;
  10017. /**
  10018. * Gets the layer id use to find what meshes are impacted by the light.
  10019. * Inactive if 0
  10020. */
  10021. /**
  10022. * Sets the layer id use to find what meshes are impacted by the light.
  10023. * Inactive if 0
  10024. */
  10025. includeOnlyWithLayerMask: number;
  10026. private _lightmapMode;
  10027. /**
  10028. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10029. */
  10030. /**
  10031. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10032. */
  10033. lightmapMode: number;
  10034. /**
  10035. * Shadow generator associted to the light.
  10036. * @hidden Internal use only.
  10037. */
  10038. _shadowGenerator: Nullable<IShadowGenerator>;
  10039. /**
  10040. * @hidden Internal use only.
  10041. */
  10042. _excludedMeshesIds: string[];
  10043. /**
  10044. * @hidden Internal use only.
  10045. */
  10046. _includedOnlyMeshesIds: string[];
  10047. /**
  10048. * The current light unifom buffer.
  10049. * @hidden Internal use only.
  10050. */
  10051. _uniformBuffer: UniformBuffer;
  10052. /** @hidden */
  10053. _renderId: number;
  10054. /**
  10055. * Creates a Light object in the scene.
  10056. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10057. * @param name The firendly name of the light
  10058. * @param scene The scene the light belongs too
  10059. */
  10060. constructor(name: string, scene: Scene);
  10061. protected abstract _buildUniformLayout(): void;
  10062. /**
  10063. * Sets the passed Effect "effect" with the Light information.
  10064. * @param effect The effect to update
  10065. * @param lightIndex The index of the light in the effect to update
  10066. * @returns The light
  10067. */
  10068. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10069. /**
  10070. * Sets the passed Effect "effect" with the Light textures.
  10071. * @param effect The effect to update
  10072. * @param lightIndex The index of the light in the effect to update
  10073. * @returns The light
  10074. */
  10075. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10076. /**
  10077. * Binds the lights information from the scene to the effect for the given mesh.
  10078. * @param lightIndex Light index
  10079. * @param scene The scene where the light belongs to
  10080. * @param effect The effect we are binding the data to
  10081. * @param useSpecular Defines if specular is supported
  10082. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10083. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10084. */
  10085. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  10086. /**
  10087. * Sets the passed Effect "effect" with the Light information.
  10088. * @param effect The effect to update
  10089. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10090. * @returns The light
  10091. */
  10092. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10093. /**
  10094. * Returns the string "Light".
  10095. * @returns the class name
  10096. */
  10097. getClassName(): string;
  10098. /** @hidden */
  10099. readonly _isLight: boolean;
  10100. /**
  10101. * Converts the light information to a readable string for debug purpose.
  10102. * @param fullDetails Supports for multiple levels of logging within scene loading
  10103. * @returns the human readable light info
  10104. */
  10105. toString(fullDetails?: boolean): string;
  10106. /** @hidden */
  10107. protected _syncParentEnabledState(): void;
  10108. /**
  10109. * Set the enabled state of this node.
  10110. * @param value - the new enabled state
  10111. */
  10112. setEnabled(value: boolean): void;
  10113. /**
  10114. * Returns the Light associated shadow generator if any.
  10115. * @return the associated shadow generator.
  10116. */
  10117. getShadowGenerator(): Nullable<IShadowGenerator>;
  10118. /**
  10119. * Returns a Vector3, the absolute light position in the World.
  10120. * @returns the world space position of the light
  10121. */
  10122. getAbsolutePosition(): Vector3;
  10123. /**
  10124. * Specifies if the light will affect the passed mesh.
  10125. * @param mesh The mesh to test against the light
  10126. * @return true the mesh is affected otherwise, false.
  10127. */
  10128. canAffectMesh(mesh: AbstractMesh): boolean;
  10129. /**
  10130. * Sort function to order lights for rendering.
  10131. * @param a First Light object to compare to second.
  10132. * @param b Second Light object to compare first.
  10133. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10134. */
  10135. static CompareLightsPriority(a: Light, b: Light): number;
  10136. /**
  10137. * Releases resources associated with this node.
  10138. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10139. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10140. */
  10141. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10142. /**
  10143. * Returns the light type ID (integer).
  10144. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10145. */
  10146. getTypeID(): number;
  10147. /**
  10148. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10149. * @returns the scaled intensity in intensity mode unit
  10150. */
  10151. getScaledIntensity(): number;
  10152. /**
  10153. * Returns a new Light object, named "name", from the current one.
  10154. * @param name The name of the cloned light
  10155. * @returns the new created light
  10156. */
  10157. clone(name: string): Nullable<Light>;
  10158. /**
  10159. * Serializes the current light into a Serialization object.
  10160. * @returns the serialized object.
  10161. */
  10162. serialize(): any;
  10163. /**
  10164. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10165. * This new light is named "name" and added to the passed scene.
  10166. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10167. * @param name The friendly name of the light
  10168. * @param scene The scene the new light will belong to
  10169. * @returns the constructor function
  10170. */
  10171. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10172. /**
  10173. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10174. * @param parsedLight The JSON representation of the light
  10175. * @param scene The scene to create the parsed light in
  10176. * @returns the created light after parsing
  10177. */
  10178. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10179. private _hookArrayForExcluded;
  10180. private _hookArrayForIncludedOnly;
  10181. private _resyncMeshes;
  10182. /**
  10183. * Forces the meshes to update their light related information in their rendering used effects
  10184. * @hidden Internal Use Only
  10185. */
  10186. _markMeshesAsLightDirty(): void;
  10187. /**
  10188. * Recomputes the cached photometric scale if needed.
  10189. */
  10190. private _computePhotometricScale;
  10191. /**
  10192. * Returns the Photometric Scale according to the light type and intensity mode.
  10193. */
  10194. private _getPhotometricScale;
  10195. /**
  10196. * Reorder the light in the scene according to their defined priority.
  10197. * @hidden Internal Use Only
  10198. */
  10199. _reorderLightsInScene(): void;
  10200. /**
  10201. * Prepares the list of defines specific to the light type.
  10202. * @param defines the list of defines
  10203. * @param lightIndex defines the index of the light for the effect
  10204. */
  10205. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10206. }
  10207. }
  10208. declare module BABYLON {
  10209. /**
  10210. * Interface used to define Action
  10211. */
  10212. export interface IAction {
  10213. /**
  10214. * Trigger for the action
  10215. */
  10216. trigger: number;
  10217. /** Options of the trigger */
  10218. triggerOptions: any;
  10219. /**
  10220. * Gets the trigger parameters
  10221. * @returns the trigger parameters
  10222. */
  10223. getTriggerParameter(): any;
  10224. /**
  10225. * Internal only - executes current action event
  10226. * @hidden
  10227. */
  10228. _executeCurrent(evt?: ActionEvent): void;
  10229. /**
  10230. * Serialize placeholder for child classes
  10231. * @param parent of child
  10232. * @returns the serialized object
  10233. */
  10234. serialize(parent: any): any;
  10235. /**
  10236. * Internal only
  10237. * @hidden
  10238. */
  10239. _prepare(): void;
  10240. /**
  10241. * Internal only - manager for action
  10242. * @hidden
  10243. */
  10244. _actionManager: AbstractActionManager;
  10245. /**
  10246. * Adds action to chain of actions, may be a DoNothingAction
  10247. * @param action defines the next action to execute
  10248. * @returns The action passed in
  10249. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10250. */
  10251. then(action: IAction): IAction;
  10252. }
  10253. /**
  10254. * The action to be carried out following a trigger
  10255. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10256. */
  10257. export class Action implements IAction {
  10258. /** the trigger, with or without parameters, for the action */
  10259. triggerOptions: any;
  10260. /**
  10261. * Trigger for the action
  10262. */
  10263. trigger: number;
  10264. /**
  10265. * Internal only - manager for action
  10266. * @hidden
  10267. */
  10268. _actionManager: ActionManager;
  10269. private _nextActiveAction;
  10270. private _child;
  10271. private _condition?;
  10272. private _triggerParameter;
  10273. /**
  10274. * An event triggered prior to action being executed.
  10275. */
  10276. onBeforeExecuteObservable: Observable<Action>;
  10277. /**
  10278. * Creates a new Action
  10279. * @param triggerOptions the trigger, with or without parameters, for the action
  10280. * @param condition an optional determinant of action
  10281. */
  10282. constructor(
  10283. /** the trigger, with or without parameters, for the action */
  10284. triggerOptions: any, condition?: Condition);
  10285. /**
  10286. * Internal only
  10287. * @hidden
  10288. */
  10289. _prepare(): void;
  10290. /**
  10291. * Gets the trigger parameters
  10292. * @returns the trigger parameters
  10293. */
  10294. getTriggerParameter(): any;
  10295. /**
  10296. * Internal only - executes current action event
  10297. * @hidden
  10298. */
  10299. _executeCurrent(evt?: ActionEvent): void;
  10300. /**
  10301. * Execute placeholder for child classes
  10302. * @param evt optional action event
  10303. */
  10304. execute(evt?: ActionEvent): void;
  10305. /**
  10306. * Skips to next active action
  10307. */
  10308. skipToNextActiveAction(): void;
  10309. /**
  10310. * Adds action to chain of actions, may be a DoNothingAction
  10311. * @param action defines the next action to execute
  10312. * @returns The action passed in
  10313. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10314. */
  10315. then(action: Action): Action;
  10316. /**
  10317. * Internal only
  10318. * @hidden
  10319. */
  10320. _getProperty(propertyPath: string): string;
  10321. /**
  10322. * Internal only
  10323. * @hidden
  10324. */
  10325. _getEffectiveTarget(target: any, propertyPath: string): any;
  10326. /**
  10327. * Serialize placeholder for child classes
  10328. * @param parent of child
  10329. * @returns the serialized object
  10330. */
  10331. serialize(parent: any): any;
  10332. /**
  10333. * Internal only called by serialize
  10334. * @hidden
  10335. */
  10336. protected _serialize(serializedAction: any, parent?: any): any;
  10337. /**
  10338. * Internal only
  10339. * @hidden
  10340. */
  10341. static _SerializeValueAsString: (value: any) => string;
  10342. /**
  10343. * Internal only
  10344. * @hidden
  10345. */
  10346. static _GetTargetProperty: (target: Node | Scene) => {
  10347. name: string;
  10348. targetType: string;
  10349. value: string;
  10350. };
  10351. }
  10352. }
  10353. declare module BABYLON {
  10354. /**
  10355. * A Condition applied to an Action
  10356. */
  10357. export class Condition {
  10358. /**
  10359. * Internal only - manager for action
  10360. * @hidden
  10361. */
  10362. _actionManager: ActionManager;
  10363. /**
  10364. * Internal only
  10365. * @hidden
  10366. */
  10367. _evaluationId: number;
  10368. /**
  10369. * Internal only
  10370. * @hidden
  10371. */
  10372. _currentResult: boolean;
  10373. /**
  10374. * Creates a new Condition
  10375. * @param actionManager the manager of the action the condition is applied to
  10376. */
  10377. constructor(actionManager: ActionManager);
  10378. /**
  10379. * Check if the current condition is valid
  10380. * @returns a boolean
  10381. */
  10382. isValid(): boolean;
  10383. /**
  10384. * Internal only
  10385. * @hidden
  10386. */
  10387. _getProperty(propertyPath: string): string;
  10388. /**
  10389. * Internal only
  10390. * @hidden
  10391. */
  10392. _getEffectiveTarget(target: any, propertyPath: string): any;
  10393. /**
  10394. * Serialize placeholder for child classes
  10395. * @returns the serialized object
  10396. */
  10397. serialize(): any;
  10398. /**
  10399. * Internal only
  10400. * @hidden
  10401. */
  10402. protected _serialize(serializedCondition: any): any;
  10403. }
  10404. /**
  10405. * Defines specific conditional operators as extensions of Condition
  10406. */
  10407. export class ValueCondition extends Condition {
  10408. /** path to specify the property of the target the conditional operator uses */
  10409. propertyPath: string;
  10410. /** the value compared by the conditional operator against the current value of the property */
  10411. value: any;
  10412. /** the conditional operator, default ValueCondition.IsEqual */
  10413. operator: number;
  10414. /**
  10415. * Internal only
  10416. * @hidden
  10417. */
  10418. private static _IsEqual;
  10419. /**
  10420. * Internal only
  10421. * @hidden
  10422. */
  10423. private static _IsDifferent;
  10424. /**
  10425. * Internal only
  10426. * @hidden
  10427. */
  10428. private static _IsGreater;
  10429. /**
  10430. * Internal only
  10431. * @hidden
  10432. */
  10433. private static _IsLesser;
  10434. /**
  10435. * returns the number for IsEqual
  10436. */
  10437. static readonly IsEqual: number;
  10438. /**
  10439. * Returns the number for IsDifferent
  10440. */
  10441. static readonly IsDifferent: number;
  10442. /**
  10443. * Returns the number for IsGreater
  10444. */
  10445. static readonly IsGreater: number;
  10446. /**
  10447. * Returns the number for IsLesser
  10448. */
  10449. static readonly IsLesser: number;
  10450. /**
  10451. * Internal only The action manager for the condition
  10452. * @hidden
  10453. */
  10454. _actionManager: ActionManager;
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. private _target;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. private _effectiveTarget;
  10465. /**
  10466. * Internal only
  10467. * @hidden
  10468. */
  10469. private _property;
  10470. /**
  10471. * Creates a new ValueCondition
  10472. * @param actionManager manager for the action the condition applies to
  10473. * @param target for the action
  10474. * @param propertyPath path to specify the property of the target the conditional operator uses
  10475. * @param value the value compared by the conditional operator against the current value of the property
  10476. * @param operator the conditional operator, default ValueCondition.IsEqual
  10477. */
  10478. constructor(actionManager: ActionManager, target: any,
  10479. /** path to specify the property of the target the conditional operator uses */
  10480. propertyPath: string,
  10481. /** the value compared by the conditional operator against the current value of the property */
  10482. value: any,
  10483. /** the conditional operator, default ValueCondition.IsEqual */
  10484. operator?: number);
  10485. /**
  10486. * Compares the given value with the property value for the specified conditional operator
  10487. * @returns the result of the comparison
  10488. */
  10489. isValid(): boolean;
  10490. /**
  10491. * Serialize the ValueCondition into a JSON compatible object
  10492. * @returns serialization object
  10493. */
  10494. serialize(): any;
  10495. /**
  10496. * Gets the name of the conditional operator for the ValueCondition
  10497. * @param operator the conditional operator
  10498. * @returns the name
  10499. */
  10500. static GetOperatorName(operator: number): string;
  10501. }
  10502. /**
  10503. * Defines a predicate condition as an extension of Condition
  10504. */
  10505. export class PredicateCondition extends Condition {
  10506. /** defines the predicate function used to validate the condition */
  10507. predicate: () => boolean;
  10508. /**
  10509. * Internal only - manager for action
  10510. * @hidden
  10511. */
  10512. _actionManager: ActionManager;
  10513. /**
  10514. * Creates a new PredicateCondition
  10515. * @param actionManager manager for the action the condition applies to
  10516. * @param predicate defines the predicate function used to validate the condition
  10517. */
  10518. constructor(actionManager: ActionManager,
  10519. /** defines the predicate function used to validate the condition */
  10520. predicate: () => boolean);
  10521. /**
  10522. * @returns the validity of the predicate condition
  10523. */
  10524. isValid(): boolean;
  10525. }
  10526. /**
  10527. * Defines a state condition as an extension of Condition
  10528. */
  10529. export class StateCondition extends Condition {
  10530. /** Value to compare with target state */
  10531. value: string;
  10532. /**
  10533. * Internal only - manager for action
  10534. * @hidden
  10535. */
  10536. _actionManager: ActionManager;
  10537. /**
  10538. * Internal only
  10539. * @hidden
  10540. */
  10541. private _target;
  10542. /**
  10543. * Creates a new StateCondition
  10544. * @param actionManager manager for the action the condition applies to
  10545. * @param target of the condition
  10546. * @param value to compare with target state
  10547. */
  10548. constructor(actionManager: ActionManager, target: any,
  10549. /** Value to compare with target state */
  10550. value: string);
  10551. /**
  10552. * Gets a boolean indicating if the current condition is met
  10553. * @returns the validity of the state
  10554. */
  10555. isValid(): boolean;
  10556. /**
  10557. * Serialize the StateCondition into a JSON compatible object
  10558. * @returns serialization object
  10559. */
  10560. serialize(): any;
  10561. }
  10562. }
  10563. declare module BABYLON {
  10564. /**
  10565. * This defines an action responsible to toggle a boolean once triggered.
  10566. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10567. */
  10568. export class SwitchBooleanAction extends Action {
  10569. /**
  10570. * The path to the boolean property in the target object
  10571. */
  10572. propertyPath: string;
  10573. private _target;
  10574. private _effectiveTarget;
  10575. private _property;
  10576. /**
  10577. * Instantiate the action
  10578. * @param triggerOptions defines the trigger options
  10579. * @param target defines the object containing the boolean
  10580. * @param propertyPath defines the path to the boolean property in the target object
  10581. * @param condition defines the trigger related conditions
  10582. */
  10583. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10584. /** @hidden */
  10585. _prepare(): void;
  10586. /**
  10587. * Execute the action toggle the boolean value.
  10588. */
  10589. execute(): void;
  10590. /**
  10591. * Serializes the actions and its related information.
  10592. * @param parent defines the object to serialize in
  10593. * @returns the serialized object
  10594. */
  10595. serialize(parent: any): any;
  10596. }
  10597. /**
  10598. * This defines an action responsible to set a the state field of the target
  10599. * to a desired value once triggered.
  10600. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10601. */
  10602. export class SetStateAction extends Action {
  10603. /**
  10604. * The value to store in the state field.
  10605. */
  10606. value: string;
  10607. private _target;
  10608. /**
  10609. * Instantiate the action
  10610. * @param triggerOptions defines the trigger options
  10611. * @param target defines the object containing the state property
  10612. * @param value defines the value to store in the state field
  10613. * @param condition defines the trigger related conditions
  10614. */
  10615. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10616. /**
  10617. * Execute the action and store the value on the target state property.
  10618. */
  10619. execute(): void;
  10620. /**
  10621. * Serializes the actions and its related information.
  10622. * @param parent defines the object to serialize in
  10623. * @returns the serialized object
  10624. */
  10625. serialize(parent: any): any;
  10626. }
  10627. /**
  10628. * This defines an action responsible to set a property of the target
  10629. * to a desired value once triggered.
  10630. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10631. */
  10632. export class SetValueAction extends Action {
  10633. /**
  10634. * The path of the property to set in the target.
  10635. */
  10636. propertyPath: string;
  10637. /**
  10638. * The value to set in the property
  10639. */
  10640. value: any;
  10641. private _target;
  10642. private _effectiveTarget;
  10643. private _property;
  10644. /**
  10645. * Instantiate the action
  10646. * @param triggerOptions defines the trigger options
  10647. * @param target defines the object containing the property
  10648. * @param propertyPath defines the path of the property to set in the target
  10649. * @param value defines the value to set in the property
  10650. * @param condition defines the trigger related conditions
  10651. */
  10652. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10653. /** @hidden */
  10654. _prepare(): void;
  10655. /**
  10656. * Execute the action and set the targetted property to the desired value.
  10657. */
  10658. execute(): void;
  10659. /**
  10660. * Serializes the actions and its related information.
  10661. * @param parent defines the object to serialize in
  10662. * @returns the serialized object
  10663. */
  10664. serialize(parent: any): any;
  10665. }
  10666. /**
  10667. * This defines an action responsible to increment the target value
  10668. * to a desired value once triggered.
  10669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10670. */
  10671. export class IncrementValueAction extends Action {
  10672. /**
  10673. * The path of the property to increment in the target.
  10674. */
  10675. propertyPath: string;
  10676. /**
  10677. * The value we should increment the property by.
  10678. */
  10679. value: any;
  10680. private _target;
  10681. private _effectiveTarget;
  10682. private _property;
  10683. /**
  10684. * Instantiate the action
  10685. * @param triggerOptions defines the trigger options
  10686. * @param target defines the object containing the property
  10687. * @param propertyPath defines the path of the property to increment in the target
  10688. * @param value defines the value value we should increment the property by
  10689. * @param condition defines the trigger related conditions
  10690. */
  10691. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10692. /** @hidden */
  10693. _prepare(): void;
  10694. /**
  10695. * Execute the action and increment the target of the value amount.
  10696. */
  10697. execute(): void;
  10698. /**
  10699. * Serializes the actions and its related information.
  10700. * @param parent defines the object to serialize in
  10701. * @returns the serialized object
  10702. */
  10703. serialize(parent: any): any;
  10704. }
  10705. /**
  10706. * This defines an action responsible to start an animation once triggered.
  10707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10708. */
  10709. export class PlayAnimationAction extends Action {
  10710. /**
  10711. * Where the animation should start (animation frame)
  10712. */
  10713. from: number;
  10714. /**
  10715. * Where the animation should stop (animation frame)
  10716. */
  10717. to: number;
  10718. /**
  10719. * Define if the animation should loop or stop after the first play.
  10720. */
  10721. loop?: boolean;
  10722. private _target;
  10723. /**
  10724. * Instantiate the action
  10725. * @param triggerOptions defines the trigger options
  10726. * @param target defines the target animation or animation name
  10727. * @param from defines from where the animation should start (animation frame)
  10728. * @param end defines where the animation should stop (animation frame)
  10729. * @param loop defines if the animation should loop or stop after the first play
  10730. * @param condition defines the trigger related conditions
  10731. */
  10732. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10733. /** @hidden */
  10734. _prepare(): void;
  10735. /**
  10736. * Execute the action and play the animation.
  10737. */
  10738. execute(): void;
  10739. /**
  10740. * Serializes the actions and its related information.
  10741. * @param parent defines the object to serialize in
  10742. * @returns the serialized object
  10743. */
  10744. serialize(parent: any): any;
  10745. }
  10746. /**
  10747. * This defines an action responsible to stop an animation once triggered.
  10748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10749. */
  10750. export class StopAnimationAction extends Action {
  10751. private _target;
  10752. /**
  10753. * Instantiate the action
  10754. * @param triggerOptions defines the trigger options
  10755. * @param target defines the target animation or animation name
  10756. * @param condition defines the trigger related conditions
  10757. */
  10758. constructor(triggerOptions: any, target: any, condition?: Condition);
  10759. /** @hidden */
  10760. _prepare(): void;
  10761. /**
  10762. * Execute the action and stop the animation.
  10763. */
  10764. execute(): void;
  10765. /**
  10766. * Serializes the actions and its related information.
  10767. * @param parent defines the object to serialize in
  10768. * @returns the serialized object
  10769. */
  10770. serialize(parent: any): any;
  10771. }
  10772. /**
  10773. * This defines an action responsible that does nothing once triggered.
  10774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10775. */
  10776. export class DoNothingAction extends Action {
  10777. /**
  10778. * Instantiate the action
  10779. * @param triggerOptions defines the trigger options
  10780. * @param condition defines the trigger related conditions
  10781. */
  10782. constructor(triggerOptions?: any, condition?: Condition);
  10783. /**
  10784. * Execute the action and do nothing.
  10785. */
  10786. execute(): void;
  10787. /**
  10788. * Serializes the actions and its related information.
  10789. * @param parent defines the object to serialize in
  10790. * @returns the serialized object
  10791. */
  10792. serialize(parent: any): any;
  10793. }
  10794. /**
  10795. * This defines an action responsible to trigger several actions once triggered.
  10796. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10797. */
  10798. export class CombineAction extends Action {
  10799. /**
  10800. * The list of aggregated animations to run.
  10801. */
  10802. children: Action[];
  10803. /**
  10804. * Instantiate the action
  10805. * @param triggerOptions defines the trigger options
  10806. * @param children defines the list of aggregated animations to run
  10807. * @param condition defines the trigger related conditions
  10808. */
  10809. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10810. /** @hidden */
  10811. _prepare(): void;
  10812. /**
  10813. * Execute the action and executes all the aggregated actions.
  10814. */
  10815. execute(evt: ActionEvent): void;
  10816. /**
  10817. * Serializes the actions and its related information.
  10818. * @param parent defines the object to serialize in
  10819. * @returns the serialized object
  10820. */
  10821. serialize(parent: any): any;
  10822. }
  10823. /**
  10824. * This defines an action responsible to run code (external event) once triggered.
  10825. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10826. */
  10827. export class ExecuteCodeAction extends Action {
  10828. /**
  10829. * The callback function to run.
  10830. */
  10831. func: (evt: ActionEvent) => void;
  10832. /**
  10833. * Instantiate the action
  10834. * @param triggerOptions defines the trigger options
  10835. * @param func defines the callback function to run
  10836. * @param condition defines the trigger related conditions
  10837. */
  10838. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10839. /**
  10840. * Execute the action and run the attached code.
  10841. */
  10842. execute(evt: ActionEvent): void;
  10843. }
  10844. /**
  10845. * This defines an action responsible to set the parent property of the target once triggered.
  10846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10847. */
  10848. export class SetParentAction extends Action {
  10849. private _parent;
  10850. private _target;
  10851. /**
  10852. * Instantiate the action
  10853. * @param triggerOptions defines the trigger options
  10854. * @param target defines the target containing the parent property
  10855. * @param parent defines from where the animation should start (animation frame)
  10856. * @param condition defines the trigger related conditions
  10857. */
  10858. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10859. /** @hidden */
  10860. _prepare(): void;
  10861. /**
  10862. * Execute the action and set the parent property.
  10863. */
  10864. execute(): void;
  10865. /**
  10866. * Serializes the actions and its related information.
  10867. * @param parent defines the object to serialize in
  10868. * @returns the serialized object
  10869. */
  10870. serialize(parent: any): any;
  10871. }
  10872. }
  10873. declare module BABYLON {
  10874. /**
  10875. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10876. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10878. */
  10879. export class ActionManager extends AbstractActionManager {
  10880. /**
  10881. * Nothing
  10882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10883. */
  10884. static readonly NothingTrigger: number;
  10885. /**
  10886. * On pick
  10887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10888. */
  10889. static readonly OnPickTrigger: number;
  10890. /**
  10891. * On left pick
  10892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10893. */
  10894. static readonly OnLeftPickTrigger: number;
  10895. /**
  10896. * On right pick
  10897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10898. */
  10899. static readonly OnRightPickTrigger: number;
  10900. /**
  10901. * On center pick
  10902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10903. */
  10904. static readonly OnCenterPickTrigger: number;
  10905. /**
  10906. * On pick down
  10907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10908. */
  10909. static readonly OnPickDownTrigger: number;
  10910. /**
  10911. * On double pick
  10912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10913. */
  10914. static readonly OnDoublePickTrigger: number;
  10915. /**
  10916. * On pick up
  10917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10918. */
  10919. static readonly OnPickUpTrigger: number;
  10920. /**
  10921. * On pick out.
  10922. * This trigger will only be raised if you also declared a OnPickDown
  10923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10924. */
  10925. static readonly OnPickOutTrigger: number;
  10926. /**
  10927. * On long press
  10928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10929. */
  10930. static readonly OnLongPressTrigger: number;
  10931. /**
  10932. * On pointer over
  10933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10934. */
  10935. static readonly OnPointerOverTrigger: number;
  10936. /**
  10937. * On pointer out
  10938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10939. */
  10940. static readonly OnPointerOutTrigger: number;
  10941. /**
  10942. * On every frame
  10943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10944. */
  10945. static readonly OnEveryFrameTrigger: number;
  10946. /**
  10947. * On intersection enter
  10948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10949. */
  10950. static readonly OnIntersectionEnterTrigger: number;
  10951. /**
  10952. * On intersection exit
  10953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10954. */
  10955. static readonly OnIntersectionExitTrigger: number;
  10956. /**
  10957. * On key down
  10958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10959. */
  10960. static readonly OnKeyDownTrigger: number;
  10961. /**
  10962. * On key up
  10963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10964. */
  10965. static readonly OnKeyUpTrigger: number;
  10966. private _scene;
  10967. /**
  10968. * Creates a new action manager
  10969. * @param scene defines the hosting scene
  10970. */
  10971. constructor(scene: Scene);
  10972. /**
  10973. * Releases all associated resources
  10974. */
  10975. dispose(): void;
  10976. /**
  10977. * Gets hosting scene
  10978. * @returns the hosting scene
  10979. */
  10980. getScene(): Scene;
  10981. /**
  10982. * Does this action manager handles actions of any of the given triggers
  10983. * @param triggers defines the triggers to be tested
  10984. * @return a boolean indicating whether one (or more) of the triggers is handled
  10985. */
  10986. hasSpecificTriggers(triggers: number[]): boolean;
  10987. /**
  10988. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10989. * speed.
  10990. * @param triggerA defines the trigger to be tested
  10991. * @param triggerB defines the trigger to be tested
  10992. * @return a boolean indicating whether one (or more) of the triggers is handled
  10993. */
  10994. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10995. /**
  10996. * Does this action manager handles actions of a given trigger
  10997. * @param trigger defines the trigger to be tested
  10998. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10999. * @return whether the trigger is handled
  11000. */
  11001. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11002. /**
  11003. * Does this action manager has pointer triggers
  11004. */
  11005. readonly hasPointerTriggers: boolean;
  11006. /**
  11007. * Does this action manager has pick triggers
  11008. */
  11009. readonly hasPickTriggers: boolean;
  11010. /**
  11011. * Registers an action to this action manager
  11012. * @param action defines the action to be registered
  11013. * @return the action amended (prepared) after registration
  11014. */
  11015. registerAction(action: IAction): Nullable<IAction>;
  11016. /**
  11017. * Unregisters an action to this action manager
  11018. * @param action defines the action to be unregistered
  11019. * @return a boolean indicating whether the action has been unregistered
  11020. */
  11021. unregisterAction(action: IAction): Boolean;
  11022. /**
  11023. * Process a specific trigger
  11024. * @param trigger defines the trigger to process
  11025. * @param evt defines the event details to be processed
  11026. */
  11027. processTrigger(trigger: number, evt?: IActionEvent): void;
  11028. /** @hidden */
  11029. _getEffectiveTarget(target: any, propertyPath: string): any;
  11030. /** @hidden */
  11031. _getProperty(propertyPath: string): string;
  11032. /**
  11033. * Serialize this manager to a JSON object
  11034. * @param name defines the property name to store this manager
  11035. * @returns a JSON representation of this manager
  11036. */
  11037. serialize(name: string): any;
  11038. /**
  11039. * Creates a new ActionManager from a JSON data
  11040. * @param parsedActions defines the JSON data to read from
  11041. * @param object defines the hosting mesh
  11042. * @param scene defines the hosting scene
  11043. */
  11044. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11045. /**
  11046. * Get a trigger name by index
  11047. * @param trigger defines the trigger index
  11048. * @returns a trigger name
  11049. */
  11050. static GetTriggerName(trigger: number): string;
  11051. }
  11052. }
  11053. declare module BABYLON {
  11054. /**
  11055. * Class representing a ray with position and direction
  11056. */
  11057. export class Ray {
  11058. /** origin point */
  11059. origin: Vector3;
  11060. /** direction */
  11061. direction: Vector3;
  11062. /** length of the ray */
  11063. length: number;
  11064. private static readonly TmpVector3;
  11065. private _tmpRay;
  11066. /**
  11067. * Creates a new ray
  11068. * @param origin origin point
  11069. * @param direction direction
  11070. * @param length length of the ray
  11071. */
  11072. constructor(
  11073. /** origin point */
  11074. origin: Vector3,
  11075. /** direction */
  11076. direction: Vector3,
  11077. /** length of the ray */
  11078. length?: number);
  11079. /**
  11080. * Checks if the ray intersects a box
  11081. * @param minimum bound of the box
  11082. * @param maximum bound of the box
  11083. * @param intersectionTreshold extra extend to be added to the box in all direction
  11084. * @returns if the box was hit
  11085. */
  11086. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11087. /**
  11088. * Checks if the ray intersects a box
  11089. * @param box the bounding box to check
  11090. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11091. * @returns if the box was hit
  11092. */
  11093. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11094. /**
  11095. * If the ray hits a sphere
  11096. * @param sphere the bounding sphere to check
  11097. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11098. * @returns true if it hits the sphere
  11099. */
  11100. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11101. /**
  11102. * If the ray hits a triange
  11103. * @param vertex0 triangle vertex
  11104. * @param vertex1 triangle vertex
  11105. * @param vertex2 triangle vertex
  11106. * @returns intersection information if hit
  11107. */
  11108. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11109. /**
  11110. * Checks if ray intersects a plane
  11111. * @param plane the plane to check
  11112. * @returns the distance away it was hit
  11113. */
  11114. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11115. /**
  11116. * Calculate the intercept of a ray on a given axis
  11117. * @param axis to check 'x' | 'y' | 'z'
  11118. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11119. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11120. */
  11121. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11122. /**
  11123. * Checks if ray intersects a mesh
  11124. * @param mesh the mesh to check
  11125. * @param fastCheck if only the bounding box should checked
  11126. * @returns picking info of the intersecton
  11127. */
  11128. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11129. /**
  11130. * Checks if ray intersects a mesh
  11131. * @param meshes the meshes to check
  11132. * @param fastCheck if only the bounding box should checked
  11133. * @param results array to store result in
  11134. * @returns Array of picking infos
  11135. */
  11136. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11137. private _comparePickingInfo;
  11138. private static smallnum;
  11139. private static rayl;
  11140. /**
  11141. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11142. * @param sega the first point of the segment to test the intersection against
  11143. * @param segb the second point of the segment to test the intersection against
  11144. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11145. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11146. */
  11147. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11148. /**
  11149. * Update the ray from viewport position
  11150. * @param x position
  11151. * @param y y position
  11152. * @param viewportWidth viewport width
  11153. * @param viewportHeight viewport height
  11154. * @param world world matrix
  11155. * @param view view matrix
  11156. * @param projection projection matrix
  11157. * @returns this ray updated
  11158. */
  11159. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11160. /**
  11161. * Creates a ray with origin and direction of 0,0,0
  11162. * @returns the new ray
  11163. */
  11164. static Zero(): Ray;
  11165. /**
  11166. * Creates a new ray from screen space and viewport
  11167. * @param x position
  11168. * @param y y position
  11169. * @param viewportWidth viewport width
  11170. * @param viewportHeight viewport height
  11171. * @param world world matrix
  11172. * @param view view matrix
  11173. * @param projection projection matrix
  11174. * @returns new ray
  11175. */
  11176. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11177. /**
  11178. * 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
  11179. * transformed to the given world matrix.
  11180. * @param origin The origin point
  11181. * @param end The end point
  11182. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11183. * @returns the new ray
  11184. */
  11185. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11186. /**
  11187. * Transforms a ray by a matrix
  11188. * @param ray ray to transform
  11189. * @param matrix matrix to apply
  11190. * @returns the resulting new ray
  11191. */
  11192. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11193. /**
  11194. * Transforms a ray by a matrix
  11195. * @param ray ray to transform
  11196. * @param matrix matrix to apply
  11197. * @param result ray to store result in
  11198. */
  11199. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11200. /**
  11201. * Unproject a ray from screen space to object space
  11202. * @param sourceX defines the screen space x coordinate to use
  11203. * @param sourceY defines the screen space y coordinate to use
  11204. * @param viewportWidth defines the current width of the viewport
  11205. * @param viewportHeight defines the current height of the viewport
  11206. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11207. * @param view defines the view matrix to use
  11208. * @param projection defines the projection matrix to use
  11209. */
  11210. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11211. }
  11212. /**
  11213. * Type used to define predicate used to select faces when a mesh intersection is detected
  11214. */
  11215. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11216. interface Scene {
  11217. /** @hidden */
  11218. _tempPickingRay: Nullable<Ray>;
  11219. /** @hidden */
  11220. _cachedRayForTransform: Ray;
  11221. /** @hidden */
  11222. _pickWithRayInverseMatrix: Matrix;
  11223. /** @hidden */
  11224. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11225. /** @hidden */
  11226. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11227. }
  11228. }
  11229. declare module BABYLON {
  11230. /**
  11231. * Groups all the scene component constants in one place to ease maintenance.
  11232. * @hidden
  11233. */
  11234. export class SceneComponentConstants {
  11235. static readonly NAME_EFFECTLAYER: string;
  11236. static readonly NAME_LAYER: string;
  11237. static readonly NAME_LENSFLARESYSTEM: string;
  11238. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11239. static readonly NAME_PARTICLESYSTEM: string;
  11240. static readonly NAME_GAMEPAD: string;
  11241. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11242. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11243. static readonly NAME_DEPTHRENDERER: string;
  11244. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11245. static readonly NAME_SPRITE: string;
  11246. static readonly NAME_OUTLINERENDERER: string;
  11247. static readonly NAME_PROCEDURALTEXTURE: string;
  11248. static readonly NAME_SHADOWGENERATOR: string;
  11249. static readonly NAME_OCTREE: string;
  11250. static readonly NAME_PHYSICSENGINE: string;
  11251. static readonly NAME_AUDIO: string;
  11252. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11253. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11254. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11255. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11256. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11257. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11258. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11259. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11260. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11261. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11262. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11263. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11264. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11265. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11266. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11267. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11268. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11269. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11270. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11271. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11272. static readonly STEP_AFTERRENDER_AUDIO: number;
  11273. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11274. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11275. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11276. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11277. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11278. static readonly STEP_POINTERMOVE_SPRITE: number;
  11279. static readonly STEP_POINTERDOWN_SPRITE: number;
  11280. static readonly STEP_POINTERUP_SPRITE: number;
  11281. }
  11282. /**
  11283. * This represents a scene component.
  11284. *
  11285. * This is used to decouple the dependency the scene is having on the different workloads like
  11286. * layers, post processes...
  11287. */
  11288. export interface ISceneComponent {
  11289. /**
  11290. * The name of the component. Each component must have a unique name.
  11291. */
  11292. name: string;
  11293. /**
  11294. * The scene the component belongs to.
  11295. */
  11296. scene: Scene;
  11297. /**
  11298. * Register the component to one instance of a scene.
  11299. */
  11300. register(): void;
  11301. /**
  11302. * Rebuilds the elements related to this component in case of
  11303. * context lost for instance.
  11304. */
  11305. rebuild(): void;
  11306. /**
  11307. * Disposes the component and the associated ressources.
  11308. */
  11309. dispose(): void;
  11310. }
  11311. /**
  11312. * This represents a SERIALIZABLE scene component.
  11313. *
  11314. * This extends Scene Component to add Serialization methods on top.
  11315. */
  11316. export interface ISceneSerializableComponent extends ISceneComponent {
  11317. /**
  11318. * Adds all the elements from the container to the scene
  11319. * @param container the container holding the elements
  11320. */
  11321. addFromContainer(container: AbstractScene): void;
  11322. /**
  11323. * Removes all the elements in the container from the scene
  11324. * @param container contains the elements to remove
  11325. * @param dispose if the removed element should be disposed (default: false)
  11326. */
  11327. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11328. /**
  11329. * Serializes the component data to the specified json object
  11330. * @param serializationObject The object to serialize to
  11331. */
  11332. serialize(serializationObject: any): void;
  11333. }
  11334. /**
  11335. * Strong typing of a Mesh related stage step action
  11336. */
  11337. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11338. /**
  11339. * Strong typing of a Evaluate Sub Mesh related stage step action
  11340. */
  11341. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11342. /**
  11343. * Strong typing of a Active Mesh related stage step action
  11344. */
  11345. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11346. /**
  11347. * Strong typing of a Camera related stage step action
  11348. */
  11349. export type CameraStageAction = (camera: Camera) => void;
  11350. /**
  11351. * Strong typing of a Camera Frame buffer related stage step action
  11352. */
  11353. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11354. /**
  11355. * Strong typing of a Render Target related stage step action
  11356. */
  11357. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11358. /**
  11359. * Strong typing of a RenderingGroup related stage step action
  11360. */
  11361. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11362. /**
  11363. * Strong typing of a Mesh Render related stage step action
  11364. */
  11365. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11366. /**
  11367. * Strong typing of a simple stage step action
  11368. */
  11369. export type SimpleStageAction = () => void;
  11370. /**
  11371. * Strong typing of a render target action.
  11372. */
  11373. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11374. /**
  11375. * Strong typing of a pointer move action.
  11376. */
  11377. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11378. /**
  11379. * Strong typing of a pointer up/down action.
  11380. */
  11381. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11382. /**
  11383. * Representation of a stage in the scene (Basically a list of ordered steps)
  11384. * @hidden
  11385. */
  11386. export class Stage<T extends Function> extends Array<{
  11387. index: number;
  11388. component: ISceneComponent;
  11389. action: T;
  11390. }> {
  11391. /**
  11392. * Hide ctor from the rest of the world.
  11393. * @param items The items to add.
  11394. */
  11395. private constructor();
  11396. /**
  11397. * Creates a new Stage.
  11398. * @returns A new instance of a Stage
  11399. */
  11400. static Create<T extends Function>(): Stage<T>;
  11401. /**
  11402. * Registers a step in an ordered way in the targeted stage.
  11403. * @param index Defines the position to register the step in
  11404. * @param component Defines the component attached to the step
  11405. * @param action Defines the action to launch during the step
  11406. */
  11407. registerStep(index: number, component: ISceneComponent, action: T): void;
  11408. /**
  11409. * Clears all the steps from the stage.
  11410. */
  11411. clear(): void;
  11412. }
  11413. }
  11414. declare module BABYLON {
  11415. interface Scene {
  11416. /** @hidden */
  11417. _pointerOverSprite: Nullable<Sprite>;
  11418. /** @hidden */
  11419. _pickedDownSprite: Nullable<Sprite>;
  11420. /** @hidden */
  11421. _tempSpritePickingRay: Nullable<Ray>;
  11422. /**
  11423. * All of the sprite managers added to this scene
  11424. * @see http://doc.babylonjs.com/babylon101/sprites
  11425. */
  11426. spriteManagers: Array<ISpriteManager>;
  11427. /**
  11428. * An event triggered when sprites rendering is about to start
  11429. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11430. */
  11431. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11432. /**
  11433. * An event triggered when sprites rendering is done
  11434. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11435. */
  11436. onAfterSpritesRenderingObservable: Observable<Scene>;
  11437. /** @hidden */
  11438. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11439. /** Launch a ray to try to pick a sprite in the scene
  11440. * @param x position on screen
  11441. * @param y position on screen
  11442. * @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
  11443. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11444. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11445. * @returns a PickingInfo
  11446. */
  11447. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11448. /** Use the given ray to pick a sprite in the scene
  11449. * @param ray The ray (in world space) to use to pick meshes
  11450. * @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
  11451. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11452. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11453. * @returns a PickingInfo
  11454. */
  11455. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11456. /** @hidden */
  11457. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11458. /** Launch a ray to try to pick sprites in the scene
  11459. * @param x position on screen
  11460. * @param y position on screen
  11461. * @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
  11462. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11463. * @returns a PickingInfo array
  11464. */
  11465. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11466. /** Use the given ray to pick sprites in the scene
  11467. * @param ray The ray (in world space) to use to pick meshes
  11468. * @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
  11469. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11470. * @returns a PickingInfo array
  11471. */
  11472. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11473. /**
  11474. * Force the sprite under the pointer
  11475. * @param sprite defines the sprite to use
  11476. */
  11477. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11478. /**
  11479. * Gets the sprite under the pointer
  11480. * @returns a Sprite or null if no sprite is under the pointer
  11481. */
  11482. getPointerOverSprite(): Nullable<Sprite>;
  11483. }
  11484. /**
  11485. * Defines the sprite scene component responsible to manage sprites
  11486. * in a given scene.
  11487. */
  11488. export class SpriteSceneComponent implements ISceneComponent {
  11489. /**
  11490. * The component name helpfull to identify the component in the list of scene components.
  11491. */
  11492. readonly name: string;
  11493. /**
  11494. * The scene the component belongs to.
  11495. */
  11496. scene: Scene;
  11497. /** @hidden */
  11498. private _spritePredicate;
  11499. /**
  11500. * Creates a new instance of the component for the given scene
  11501. * @param scene Defines the scene to register the component in
  11502. */
  11503. constructor(scene: Scene);
  11504. /**
  11505. * Registers the component in a given scene
  11506. */
  11507. register(): void;
  11508. /**
  11509. * Rebuilds the elements related to this component in case of
  11510. * context lost for instance.
  11511. */
  11512. rebuild(): void;
  11513. /**
  11514. * Disposes the component and the associated ressources.
  11515. */
  11516. dispose(): void;
  11517. private _pickSpriteButKeepRay;
  11518. private _pointerMove;
  11519. private _pointerDown;
  11520. private _pointerUp;
  11521. }
  11522. }
  11523. declare module BABYLON {
  11524. /** @hidden */
  11525. export var fogFragmentDeclaration: {
  11526. name: string;
  11527. shader: string;
  11528. };
  11529. }
  11530. declare module BABYLON {
  11531. /** @hidden */
  11532. export var fogFragment: {
  11533. name: string;
  11534. shader: string;
  11535. };
  11536. }
  11537. declare module BABYLON {
  11538. /** @hidden */
  11539. export var spritesPixelShader: {
  11540. name: string;
  11541. shader: string;
  11542. };
  11543. }
  11544. declare module BABYLON {
  11545. /** @hidden */
  11546. export var fogVertexDeclaration: {
  11547. name: string;
  11548. shader: string;
  11549. };
  11550. }
  11551. declare module BABYLON {
  11552. /** @hidden */
  11553. export var spritesVertexShader: {
  11554. name: string;
  11555. shader: string;
  11556. };
  11557. }
  11558. declare module BABYLON {
  11559. /**
  11560. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11561. */
  11562. export interface ISpriteManager extends IDisposable {
  11563. /**
  11564. * Restricts the camera to viewing objects with the same layerMask.
  11565. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11566. */
  11567. layerMask: number;
  11568. /**
  11569. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11570. */
  11571. isPickable: boolean;
  11572. /**
  11573. * Specifies the rendering group id for this mesh (0 by default)
  11574. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11575. */
  11576. renderingGroupId: number;
  11577. /**
  11578. * Defines the list of sprites managed by the manager.
  11579. */
  11580. sprites: Array<Sprite>;
  11581. /**
  11582. * Tests the intersection of a sprite with a specific ray.
  11583. * @param ray The ray we are sending to test the collision
  11584. * @param camera The camera space we are sending rays in
  11585. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11586. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11587. * @returns picking info or null.
  11588. */
  11589. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11590. /**
  11591. * Intersects the sprites with a ray
  11592. * @param ray defines the ray to intersect with
  11593. * @param camera defines the current active camera
  11594. * @param predicate defines a predicate used to select candidate sprites
  11595. * @returns null if no hit or a PickingInfo array
  11596. */
  11597. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11598. /**
  11599. * Renders the list of sprites on screen.
  11600. */
  11601. render(): void;
  11602. }
  11603. /**
  11604. * Class used to manage multiple sprites on the same spritesheet
  11605. * @see http://doc.babylonjs.com/babylon101/sprites
  11606. */
  11607. export class SpriteManager implements ISpriteManager {
  11608. /** defines the manager's name */
  11609. name: string;
  11610. /** Gets the list of sprites */
  11611. sprites: Sprite[];
  11612. /** Gets or sets the rendering group id (0 by default) */
  11613. renderingGroupId: number;
  11614. /** Gets or sets camera layer mask */
  11615. layerMask: number;
  11616. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11617. fogEnabled: boolean;
  11618. /** Gets or sets a boolean indicating if the sprites are pickable */
  11619. isPickable: boolean;
  11620. /** Defines the default width of a cell in the spritesheet */
  11621. cellWidth: number;
  11622. /** Defines the default height of a cell in the spritesheet */
  11623. cellHeight: number;
  11624. /** Associative array from JSON sprite data file */
  11625. private _cellData;
  11626. /** Array of sprite names from JSON sprite data file */
  11627. private _spriteMap;
  11628. /** True when packed cell data from JSON file is ready*/
  11629. private _packedAndReady;
  11630. /**
  11631. * An event triggered when the manager is disposed.
  11632. */
  11633. onDisposeObservable: Observable<SpriteManager>;
  11634. private _onDisposeObserver;
  11635. /**
  11636. * Callback called when the manager is disposed
  11637. */
  11638. onDispose: () => void;
  11639. private _capacity;
  11640. private _fromPacked;
  11641. private _spriteTexture;
  11642. private _epsilon;
  11643. private _scene;
  11644. private _vertexData;
  11645. private _buffer;
  11646. private _vertexBuffers;
  11647. private _indexBuffer;
  11648. private _effectBase;
  11649. private _effectFog;
  11650. /**
  11651. * Gets or sets the spritesheet texture
  11652. */
  11653. texture: Texture;
  11654. /**
  11655. * Creates a new sprite manager
  11656. * @param name defines the manager's name
  11657. * @param imgUrl defines the sprite sheet url
  11658. * @param capacity defines the maximum allowed number of sprites
  11659. * @param cellSize defines the size of a sprite cell
  11660. * @param scene defines the hosting scene
  11661. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11662. * @param samplingMode defines the smapling mode to use with spritesheet
  11663. * @param fromPacked set to false; do not alter
  11664. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11665. */
  11666. constructor(
  11667. /** defines the manager's name */
  11668. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11669. private _makePacked;
  11670. private _appendSpriteVertex;
  11671. /**
  11672. * Intersects the sprites with a ray
  11673. * @param ray defines the ray to intersect with
  11674. * @param camera defines the current active camera
  11675. * @param predicate defines a predicate used to select candidate sprites
  11676. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11677. * @returns null if no hit or a PickingInfo
  11678. */
  11679. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11680. /**
  11681. * Intersects the sprites with a ray
  11682. * @param ray defines the ray to intersect with
  11683. * @param camera defines the current active camera
  11684. * @param predicate defines a predicate used to select candidate sprites
  11685. * @returns null if no hit or a PickingInfo array
  11686. */
  11687. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11688. /**
  11689. * Render all child sprites
  11690. */
  11691. render(): void;
  11692. /**
  11693. * Release associated resources
  11694. */
  11695. dispose(): void;
  11696. }
  11697. }
  11698. declare module BABYLON {
  11699. /**
  11700. * Class used to represent a sprite
  11701. * @see http://doc.babylonjs.com/babylon101/sprites
  11702. */
  11703. export class Sprite {
  11704. /** defines the name */
  11705. name: string;
  11706. /** Gets or sets the current world position */
  11707. position: Vector3;
  11708. /** Gets or sets the main color */
  11709. color: Color4;
  11710. /** Gets or sets the width */
  11711. width: number;
  11712. /** Gets or sets the height */
  11713. height: number;
  11714. /** Gets or sets rotation angle */
  11715. angle: number;
  11716. /** Gets or sets the cell index in the sprite sheet */
  11717. cellIndex: number;
  11718. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11719. cellRef: string;
  11720. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11721. invertU: number;
  11722. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11723. invertV: number;
  11724. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11725. disposeWhenFinishedAnimating: boolean;
  11726. /** Gets the list of attached animations */
  11727. animations: Animation[];
  11728. /** Gets or sets a boolean indicating if the sprite can be picked */
  11729. isPickable: boolean;
  11730. /**
  11731. * Gets or sets the associated action manager
  11732. */
  11733. actionManager: Nullable<ActionManager>;
  11734. private _animationStarted;
  11735. private _loopAnimation;
  11736. private _fromIndex;
  11737. private _toIndex;
  11738. private _delay;
  11739. private _direction;
  11740. private _manager;
  11741. private _time;
  11742. private _onAnimationEnd;
  11743. /**
  11744. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11745. */
  11746. isVisible: boolean;
  11747. /**
  11748. * Gets or sets the sprite size
  11749. */
  11750. size: number;
  11751. /**
  11752. * Creates a new Sprite
  11753. * @param name defines the name
  11754. * @param manager defines the manager
  11755. */
  11756. constructor(
  11757. /** defines the name */
  11758. name: string, manager: ISpriteManager);
  11759. /**
  11760. * Starts an animation
  11761. * @param from defines the initial key
  11762. * @param to defines the end key
  11763. * @param loop defines if the animation must loop
  11764. * @param delay defines the start delay (in ms)
  11765. * @param onAnimationEnd defines a callback to call when animation ends
  11766. */
  11767. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11768. /** Stops current animation (if any) */
  11769. stopAnimation(): void;
  11770. /** @hidden */
  11771. _animate(deltaTime: number): void;
  11772. /** Release associated resources */
  11773. dispose(): void;
  11774. }
  11775. }
  11776. declare module BABYLON {
  11777. /**
  11778. * Information about the result of picking within a scene
  11779. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11780. */
  11781. export class PickingInfo {
  11782. /** @hidden */
  11783. _pickingUnavailable: boolean;
  11784. /**
  11785. * If the pick collided with an object
  11786. */
  11787. hit: boolean;
  11788. /**
  11789. * Distance away where the pick collided
  11790. */
  11791. distance: number;
  11792. /**
  11793. * The location of pick collision
  11794. */
  11795. pickedPoint: Nullable<Vector3>;
  11796. /**
  11797. * The mesh corresponding the the pick collision
  11798. */
  11799. pickedMesh: Nullable<AbstractMesh>;
  11800. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11801. bu: number;
  11802. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11803. bv: number;
  11804. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11805. faceId: number;
  11806. /** Id of the the submesh that was picked */
  11807. subMeshId: number;
  11808. /** If a sprite was picked, this will be the sprite the pick collided with */
  11809. pickedSprite: Nullable<Sprite>;
  11810. /**
  11811. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11812. */
  11813. originMesh: Nullable<AbstractMesh>;
  11814. /**
  11815. * The ray that was used to perform the picking.
  11816. */
  11817. ray: Nullable<Ray>;
  11818. /**
  11819. * Gets the normal correspodning to the face the pick collided with
  11820. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11821. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11822. * @returns The normal correspodning to the face the pick collided with
  11823. */
  11824. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11825. /**
  11826. * Gets the texture coordinates of where the pick occured
  11827. * @returns the vector containing the coordnates of the texture
  11828. */
  11829. getTextureCoordinates(): Nullable<Vector2>;
  11830. }
  11831. }
  11832. declare module BABYLON {
  11833. /**
  11834. * Gather the list of pointer event types as constants.
  11835. */
  11836. export class PointerEventTypes {
  11837. /**
  11838. * 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.
  11839. */
  11840. static readonly POINTERDOWN: number;
  11841. /**
  11842. * The pointerup event is fired when a pointer is no longer active.
  11843. */
  11844. static readonly POINTERUP: number;
  11845. /**
  11846. * The pointermove event is fired when a pointer changes coordinates.
  11847. */
  11848. static readonly POINTERMOVE: number;
  11849. /**
  11850. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11851. */
  11852. static readonly POINTERWHEEL: number;
  11853. /**
  11854. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11855. */
  11856. static readonly POINTERPICK: number;
  11857. /**
  11858. * The pointertap event is fired when a the object has been touched and released without drag.
  11859. */
  11860. static readonly POINTERTAP: number;
  11861. /**
  11862. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11863. */
  11864. static readonly POINTERDOUBLETAP: number;
  11865. }
  11866. /**
  11867. * Base class of pointer info types.
  11868. */
  11869. export class PointerInfoBase {
  11870. /**
  11871. * Defines the type of event (PointerEventTypes)
  11872. */
  11873. type: number;
  11874. /**
  11875. * Defines the related dom event
  11876. */
  11877. event: PointerEvent | MouseWheelEvent;
  11878. /**
  11879. * Instantiates the base class of pointers info.
  11880. * @param type Defines the type of event (PointerEventTypes)
  11881. * @param event Defines the related dom event
  11882. */
  11883. constructor(
  11884. /**
  11885. * Defines the type of event (PointerEventTypes)
  11886. */
  11887. type: number,
  11888. /**
  11889. * Defines the related dom event
  11890. */
  11891. event: PointerEvent | MouseWheelEvent);
  11892. }
  11893. /**
  11894. * This class is used to store pointer related info for the onPrePointerObservable event.
  11895. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11896. */
  11897. export class PointerInfoPre extends PointerInfoBase {
  11898. /**
  11899. * Ray from a pointer if availible (eg. 6dof controller)
  11900. */
  11901. ray: Nullable<Ray>;
  11902. /**
  11903. * Defines the local position of the pointer on the canvas.
  11904. */
  11905. localPosition: Vector2;
  11906. /**
  11907. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11908. */
  11909. skipOnPointerObservable: boolean;
  11910. /**
  11911. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11912. * @param type Defines the type of event (PointerEventTypes)
  11913. * @param event Defines the related dom event
  11914. * @param localX Defines the local x coordinates of the pointer when the event occured
  11915. * @param localY Defines the local y coordinates of the pointer when the event occured
  11916. */
  11917. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11918. }
  11919. /**
  11920. * This type contains all the data related to a pointer event in Babylon.js.
  11921. * 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.
  11922. */
  11923. export class PointerInfo extends PointerInfoBase {
  11924. /**
  11925. * Defines the picking info associated to the info (if any)\
  11926. */
  11927. pickInfo: Nullable<PickingInfo>;
  11928. /**
  11929. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11930. * @param type Defines the type of event (PointerEventTypes)
  11931. * @param event Defines the related dom event
  11932. * @param pickInfo Defines the picking info associated to the info (if any)\
  11933. */
  11934. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11935. /**
  11936. * Defines the picking info associated to the info (if any)\
  11937. */
  11938. pickInfo: Nullable<PickingInfo>);
  11939. }
  11940. /**
  11941. * Data relating to a touch event on the screen.
  11942. */
  11943. export interface PointerTouch {
  11944. /**
  11945. * X coordinate of touch.
  11946. */
  11947. x: number;
  11948. /**
  11949. * Y coordinate of touch.
  11950. */
  11951. y: number;
  11952. /**
  11953. * Id of touch. Unique for each finger.
  11954. */
  11955. pointerId: number;
  11956. /**
  11957. * Event type passed from DOM.
  11958. */
  11959. type: any;
  11960. }
  11961. }
  11962. declare module BABYLON {
  11963. /**
  11964. * Manage the mouse inputs to control the movement of a free camera.
  11965. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11966. */
  11967. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11968. /**
  11969. * Define if touch is enabled in the mouse input
  11970. */
  11971. touchEnabled: boolean;
  11972. /**
  11973. * Defines the camera the input is attached to.
  11974. */
  11975. camera: FreeCamera;
  11976. /**
  11977. * Defines the buttons associated with the input to handle camera move.
  11978. */
  11979. buttons: number[];
  11980. /**
  11981. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11982. */
  11983. angularSensibility: number;
  11984. private _pointerInput;
  11985. private _onMouseMove;
  11986. private _observer;
  11987. private previousPosition;
  11988. /**
  11989. * Observable for when a pointer move event occurs containing the move offset
  11990. */
  11991. onPointerMovedObservable: Observable<{
  11992. offsetX: number;
  11993. offsetY: number;
  11994. }>;
  11995. /**
  11996. * @hidden
  11997. * If the camera should be rotated automatically based on pointer movement
  11998. */
  11999. _allowCameraRotation: boolean;
  12000. /**
  12001. * Manage the mouse inputs to control the movement of a free camera.
  12002. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12003. * @param touchEnabled Defines if touch is enabled or not
  12004. */
  12005. constructor(
  12006. /**
  12007. * Define if touch is enabled in the mouse input
  12008. */
  12009. touchEnabled?: boolean);
  12010. /**
  12011. * Attach the input controls to a specific dom element to get the input from.
  12012. * @param element Defines the element the controls should be listened from
  12013. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12014. */
  12015. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12016. /**
  12017. * Called on JS contextmenu event.
  12018. * Override this method to provide functionality.
  12019. */
  12020. protected onContextMenu(evt: PointerEvent): void;
  12021. /**
  12022. * Detach the current controls from the specified dom element.
  12023. * @param element Defines the element to stop listening the inputs from
  12024. */
  12025. detachControl(element: Nullable<HTMLElement>): void;
  12026. /**
  12027. * Gets the class name of the current intput.
  12028. * @returns the class name
  12029. */
  12030. getClassName(): string;
  12031. /**
  12032. * Get the friendly name associated with the input class.
  12033. * @returns the input friendly name
  12034. */
  12035. getSimpleName(): string;
  12036. }
  12037. }
  12038. declare module BABYLON {
  12039. /**
  12040. * Manage the touch inputs to control the movement of a free camera.
  12041. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12042. */
  12043. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12044. /**
  12045. * Defines the camera the input is attached to.
  12046. */
  12047. camera: FreeCamera;
  12048. /**
  12049. * Defines the touch sensibility for rotation.
  12050. * The higher the faster.
  12051. */
  12052. touchAngularSensibility: number;
  12053. /**
  12054. * Defines the touch sensibility for move.
  12055. * The higher the faster.
  12056. */
  12057. touchMoveSensibility: number;
  12058. private _offsetX;
  12059. private _offsetY;
  12060. private _pointerPressed;
  12061. private _pointerInput;
  12062. private _observer;
  12063. private _onLostFocus;
  12064. /**
  12065. * Attach the input controls to a specific dom element to get the input from.
  12066. * @param element Defines the element the controls should be listened from
  12067. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12068. */
  12069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12070. /**
  12071. * Detach the current controls from the specified dom element.
  12072. * @param element Defines the element to stop listening the inputs from
  12073. */
  12074. detachControl(element: Nullable<HTMLElement>): void;
  12075. /**
  12076. * Update the current camera state depending on the inputs that have been used this frame.
  12077. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12078. */
  12079. checkInputs(): void;
  12080. /**
  12081. * Gets the class name of the current intput.
  12082. * @returns the class name
  12083. */
  12084. getClassName(): string;
  12085. /**
  12086. * Get the friendly name associated with the input class.
  12087. * @returns the input friendly name
  12088. */
  12089. getSimpleName(): string;
  12090. }
  12091. }
  12092. declare module BABYLON {
  12093. /**
  12094. * Default Inputs manager for the FreeCamera.
  12095. * It groups all the default supported inputs for ease of use.
  12096. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12097. */
  12098. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12099. /**
  12100. * @hidden
  12101. */
  12102. _mouseInput: Nullable<FreeCameraMouseInput>;
  12103. /**
  12104. * Instantiates a new FreeCameraInputsManager.
  12105. * @param camera Defines the camera the inputs belong to
  12106. */
  12107. constructor(camera: FreeCamera);
  12108. /**
  12109. * Add keyboard input support to the input manager.
  12110. * @returns the current input manager
  12111. */
  12112. addKeyboard(): FreeCameraInputsManager;
  12113. /**
  12114. * Add mouse input support to the input manager.
  12115. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12116. * @returns the current input manager
  12117. */
  12118. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12119. /**
  12120. * Removes the mouse input support from the manager
  12121. * @returns the current input manager
  12122. */
  12123. removeMouse(): FreeCameraInputsManager;
  12124. /**
  12125. * Add touch input support to the input manager.
  12126. * @returns the current input manager
  12127. */
  12128. addTouch(): FreeCameraInputsManager;
  12129. /**
  12130. * Remove all attached input methods from a camera
  12131. */
  12132. clear(): void;
  12133. }
  12134. }
  12135. declare module BABYLON {
  12136. /**
  12137. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12138. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12139. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12140. */
  12141. export class FreeCamera extends TargetCamera {
  12142. /**
  12143. * Define the collision ellipsoid of the camera.
  12144. * This is helpful to simulate a camera body like the player body around the camera
  12145. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12146. */
  12147. ellipsoid: Vector3;
  12148. /**
  12149. * Define an offset for the position of the ellipsoid around the camera.
  12150. * This can be helpful to determine the center of the body near the gravity center of the body
  12151. * instead of its head.
  12152. */
  12153. ellipsoidOffset: Vector3;
  12154. /**
  12155. * Enable or disable collisions of the camera with the rest of the scene objects.
  12156. */
  12157. checkCollisions: boolean;
  12158. /**
  12159. * Enable or disable gravity on the camera.
  12160. */
  12161. applyGravity: boolean;
  12162. /**
  12163. * Define the input manager associated to the camera.
  12164. */
  12165. inputs: FreeCameraInputsManager;
  12166. /**
  12167. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12168. * Higher values reduce sensitivity.
  12169. */
  12170. /**
  12171. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12172. * Higher values reduce sensitivity.
  12173. */
  12174. angularSensibility: number;
  12175. /**
  12176. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12177. */
  12178. keysUp: number[];
  12179. /**
  12180. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12181. */
  12182. keysDown: number[];
  12183. /**
  12184. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12185. */
  12186. keysLeft: number[];
  12187. /**
  12188. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12189. */
  12190. keysRight: number[];
  12191. /**
  12192. * Event raised when the camera collide with a mesh in the scene.
  12193. */
  12194. onCollide: (collidedMesh: AbstractMesh) => void;
  12195. private _collider;
  12196. private _needMoveForGravity;
  12197. private _oldPosition;
  12198. private _diffPosition;
  12199. private _newPosition;
  12200. /** @hidden */
  12201. _localDirection: Vector3;
  12202. /** @hidden */
  12203. _transformedDirection: Vector3;
  12204. /**
  12205. * Instantiates a Free Camera.
  12206. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12207. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12208. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12209. * @param name Define the name of the camera in the scene
  12210. * @param position Define the start position of the camera in the scene
  12211. * @param scene Define the scene the camera belongs to
  12212. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12213. */
  12214. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12215. /**
  12216. * Attached controls to the current camera.
  12217. * @param element Defines the element the controls should be listened from
  12218. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12219. */
  12220. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12221. /**
  12222. * Detach the current controls from the camera.
  12223. * The camera will stop reacting to inputs.
  12224. * @param element Defines the element to stop listening the inputs from
  12225. */
  12226. detachControl(element: HTMLElement): void;
  12227. private _collisionMask;
  12228. /**
  12229. * Define a collision mask to limit the list of object the camera can collide with
  12230. */
  12231. collisionMask: number;
  12232. /** @hidden */
  12233. _collideWithWorld(displacement: Vector3): void;
  12234. private _onCollisionPositionChange;
  12235. /** @hidden */
  12236. _checkInputs(): void;
  12237. /** @hidden */
  12238. _decideIfNeedsToMove(): boolean;
  12239. /** @hidden */
  12240. _updatePosition(): void;
  12241. /**
  12242. * Destroy the camera and release the current resources hold by it.
  12243. */
  12244. dispose(): void;
  12245. /**
  12246. * Gets the current object class name.
  12247. * @return the class name
  12248. */
  12249. getClassName(): string;
  12250. }
  12251. }
  12252. declare module BABYLON {
  12253. /**
  12254. * Represents a gamepad control stick position
  12255. */
  12256. export class StickValues {
  12257. /**
  12258. * The x component of the control stick
  12259. */
  12260. x: number;
  12261. /**
  12262. * The y component of the control stick
  12263. */
  12264. y: number;
  12265. /**
  12266. * Initializes the gamepad x and y control stick values
  12267. * @param x The x component of the gamepad control stick value
  12268. * @param y The y component of the gamepad control stick value
  12269. */
  12270. constructor(
  12271. /**
  12272. * The x component of the control stick
  12273. */
  12274. x: number,
  12275. /**
  12276. * The y component of the control stick
  12277. */
  12278. y: number);
  12279. }
  12280. /**
  12281. * An interface which manages callbacks for gamepad button changes
  12282. */
  12283. export interface GamepadButtonChanges {
  12284. /**
  12285. * Called when a gamepad has been changed
  12286. */
  12287. changed: boolean;
  12288. /**
  12289. * Called when a gamepad press event has been triggered
  12290. */
  12291. pressChanged: boolean;
  12292. /**
  12293. * Called when a touch event has been triggered
  12294. */
  12295. touchChanged: boolean;
  12296. /**
  12297. * Called when a value has changed
  12298. */
  12299. valueChanged: boolean;
  12300. }
  12301. /**
  12302. * Represents a gamepad
  12303. */
  12304. export class Gamepad {
  12305. /**
  12306. * The id of the gamepad
  12307. */
  12308. id: string;
  12309. /**
  12310. * The index of the gamepad
  12311. */
  12312. index: number;
  12313. /**
  12314. * The browser gamepad
  12315. */
  12316. browserGamepad: any;
  12317. /**
  12318. * Specifies what type of gamepad this represents
  12319. */
  12320. type: number;
  12321. private _leftStick;
  12322. private _rightStick;
  12323. /** @hidden */
  12324. _isConnected: boolean;
  12325. private _leftStickAxisX;
  12326. private _leftStickAxisY;
  12327. private _rightStickAxisX;
  12328. private _rightStickAxisY;
  12329. /**
  12330. * Triggered when the left control stick has been changed
  12331. */
  12332. private _onleftstickchanged;
  12333. /**
  12334. * Triggered when the right control stick has been changed
  12335. */
  12336. private _onrightstickchanged;
  12337. /**
  12338. * Represents a gamepad controller
  12339. */
  12340. static GAMEPAD: number;
  12341. /**
  12342. * Represents a generic controller
  12343. */
  12344. static GENERIC: number;
  12345. /**
  12346. * Represents an XBox controller
  12347. */
  12348. static XBOX: number;
  12349. /**
  12350. * Represents a pose-enabled controller
  12351. */
  12352. static POSE_ENABLED: number;
  12353. /**
  12354. * Represents an Dual Shock controller
  12355. */
  12356. static DUALSHOCK: number;
  12357. /**
  12358. * Specifies whether the left control stick should be Y-inverted
  12359. */
  12360. protected _invertLeftStickY: boolean;
  12361. /**
  12362. * Specifies if the gamepad has been connected
  12363. */
  12364. readonly isConnected: boolean;
  12365. /**
  12366. * Initializes the gamepad
  12367. * @param id The id of the gamepad
  12368. * @param index The index of the gamepad
  12369. * @param browserGamepad The browser gamepad
  12370. * @param leftStickX The x component of the left joystick
  12371. * @param leftStickY The y component of the left joystick
  12372. * @param rightStickX The x component of the right joystick
  12373. * @param rightStickY The y component of the right joystick
  12374. */
  12375. constructor(
  12376. /**
  12377. * The id of the gamepad
  12378. */
  12379. id: string,
  12380. /**
  12381. * The index of the gamepad
  12382. */
  12383. index: number,
  12384. /**
  12385. * The browser gamepad
  12386. */
  12387. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12388. /**
  12389. * Callback triggered when the left joystick has changed
  12390. * @param callback
  12391. */
  12392. onleftstickchanged(callback: (values: StickValues) => void): void;
  12393. /**
  12394. * Callback triggered when the right joystick has changed
  12395. * @param callback
  12396. */
  12397. onrightstickchanged(callback: (values: StickValues) => void): void;
  12398. /**
  12399. * Gets the left joystick
  12400. */
  12401. /**
  12402. * Sets the left joystick values
  12403. */
  12404. leftStick: StickValues;
  12405. /**
  12406. * Gets the right joystick
  12407. */
  12408. /**
  12409. * Sets the right joystick value
  12410. */
  12411. rightStick: StickValues;
  12412. /**
  12413. * Updates the gamepad joystick positions
  12414. */
  12415. update(): void;
  12416. /**
  12417. * Disposes the gamepad
  12418. */
  12419. dispose(): void;
  12420. }
  12421. /**
  12422. * Represents a generic gamepad
  12423. */
  12424. export class GenericPad extends Gamepad {
  12425. private _buttons;
  12426. private _onbuttondown;
  12427. private _onbuttonup;
  12428. /**
  12429. * Observable triggered when a button has been pressed
  12430. */
  12431. onButtonDownObservable: Observable<number>;
  12432. /**
  12433. * Observable triggered when a button has been released
  12434. */
  12435. onButtonUpObservable: Observable<number>;
  12436. /**
  12437. * Callback triggered when a button has been pressed
  12438. * @param callback Called when a button has been pressed
  12439. */
  12440. onbuttondown(callback: (buttonPressed: number) => void): void;
  12441. /**
  12442. * Callback triggered when a button has been released
  12443. * @param callback Called when a button has been released
  12444. */
  12445. onbuttonup(callback: (buttonReleased: number) => void): void;
  12446. /**
  12447. * Initializes the generic gamepad
  12448. * @param id The id of the generic gamepad
  12449. * @param index The index of the generic gamepad
  12450. * @param browserGamepad The browser gamepad
  12451. */
  12452. constructor(id: string, index: number, browserGamepad: any);
  12453. private _setButtonValue;
  12454. /**
  12455. * Updates the generic gamepad
  12456. */
  12457. update(): void;
  12458. /**
  12459. * Disposes the generic gamepad
  12460. */
  12461. dispose(): void;
  12462. }
  12463. }
  12464. declare module BABYLON {
  12465. interface Engine {
  12466. /**
  12467. * Creates a raw texture
  12468. * @param data defines the data to store in the texture
  12469. * @param width defines the width of the texture
  12470. * @param height defines the height of the texture
  12471. * @param format defines the format of the data
  12472. * @param generateMipMaps defines if the engine should generate the mip levels
  12473. * @param invertY defines if data must be stored with Y axis inverted
  12474. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12475. * @param compression defines the compression used (null by default)
  12476. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12477. * @returns the raw texture inside an InternalTexture
  12478. */
  12479. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12480. /**
  12481. * Update a raw texture
  12482. * @param texture defines the texture to update
  12483. * @param data defines the data to store in the texture
  12484. * @param format defines the format of the data
  12485. * @param invertY defines if data must be stored with Y axis inverted
  12486. */
  12487. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12488. /**
  12489. * Update a raw texture
  12490. * @param texture defines the texture to update
  12491. * @param data defines the data to store in the texture
  12492. * @param format defines the format of the data
  12493. * @param invertY defines if data must be stored with Y axis inverted
  12494. * @param compression defines the compression used (null by default)
  12495. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12496. */
  12497. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12498. /**
  12499. * Creates a new raw cube texture
  12500. * @param data defines the array of data to use to create each face
  12501. * @param size defines the size of the textures
  12502. * @param format defines the format of the data
  12503. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12504. * @param generateMipMaps defines if the engine should generate the mip levels
  12505. * @param invertY defines if data must be stored with Y axis inverted
  12506. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12507. * @param compression defines the compression used (null by default)
  12508. * @returns the cube texture as an InternalTexture
  12509. */
  12510. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12511. /**
  12512. * Update a raw cube texture
  12513. * @param texture defines the texture to udpdate
  12514. * @param data defines the data to store
  12515. * @param format defines the data format
  12516. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12517. * @param invertY defines if data must be stored with Y axis inverted
  12518. */
  12519. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12520. /**
  12521. * Update a raw cube texture
  12522. * @param texture defines the texture to udpdate
  12523. * @param data defines the data to store
  12524. * @param format defines the data format
  12525. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12526. * @param invertY defines if data must be stored with Y axis inverted
  12527. * @param compression defines the compression used (null by default)
  12528. */
  12529. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12530. /**
  12531. * Update a raw cube texture
  12532. * @param texture defines the texture to udpdate
  12533. * @param data defines the data to store
  12534. * @param format defines the data format
  12535. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12536. * @param invertY defines if data must be stored with Y axis inverted
  12537. * @param compression defines the compression used (null by default)
  12538. * @param level defines which level of the texture to update
  12539. */
  12540. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12541. /**
  12542. * Creates a new raw cube texture from a specified url
  12543. * @param url defines the url where the data is located
  12544. * @param scene defines the current scene
  12545. * @param size defines the size of the textures
  12546. * @param format defines the format of the data
  12547. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12548. * @param noMipmap defines if the engine should avoid generating the mip levels
  12549. * @param callback defines a callback used to extract texture data from loaded data
  12550. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12551. * @param onLoad defines a callback called when texture is loaded
  12552. * @param onError defines a callback called if there is an error
  12553. * @returns the cube texture as an InternalTexture
  12554. */
  12555. 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;
  12556. /**
  12557. * Creates a new raw cube texture from a specified url
  12558. * @param url defines the url where the data is located
  12559. * @param scene defines the current scene
  12560. * @param size defines the size of the textures
  12561. * @param format defines the format of the data
  12562. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12563. * @param noMipmap defines if the engine should avoid generating the mip levels
  12564. * @param callback defines a callback used to extract texture data from loaded data
  12565. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12566. * @param onLoad defines a callback called when texture is loaded
  12567. * @param onError defines a callback called if there is an error
  12568. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12569. * @param invertY defines if data must be stored with Y axis inverted
  12570. * @returns the cube texture as an InternalTexture
  12571. */
  12572. 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;
  12573. /**
  12574. * Creates a new raw 3D texture
  12575. * @param data defines the data used to create the texture
  12576. * @param width defines the width of the texture
  12577. * @param height defines the height of the texture
  12578. * @param depth defines the depth of the texture
  12579. * @param format defines the format of the texture
  12580. * @param generateMipMaps defines if the engine must generate mip levels
  12581. * @param invertY defines if data must be stored with Y axis inverted
  12582. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12583. * @param compression defines the compressed used (can be null)
  12584. * @param textureType defines the compressed used (can be null)
  12585. * @returns a new raw 3D texture (stored in an InternalTexture)
  12586. */
  12587. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12588. /**
  12589. * Update a raw 3D texture
  12590. * @param texture defines the texture to update
  12591. * @param data defines the data to store
  12592. * @param format defines the data format
  12593. * @param invertY defines if data must be stored with Y axis inverted
  12594. */
  12595. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12596. /**
  12597. * Update a raw 3D texture
  12598. * @param texture defines the texture to update
  12599. * @param data defines the data to store
  12600. * @param format defines the data format
  12601. * @param invertY defines if data must be stored with Y axis inverted
  12602. * @param compression defines the used compression (can be null)
  12603. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12604. */
  12605. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12606. /**
  12607. * Creates a new raw 2D array texture
  12608. * @param data defines the data used to create the texture
  12609. * @param width defines the width of the texture
  12610. * @param height defines the height of the texture
  12611. * @param depth defines the number of layers of the texture
  12612. * @param format defines the format of the texture
  12613. * @param generateMipMaps defines if the engine must generate mip levels
  12614. * @param invertY defines if data must be stored with Y axis inverted
  12615. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12616. * @param compression defines the compressed used (can be null)
  12617. * @param textureType defines the compressed used (can be null)
  12618. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12619. */
  12620. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12621. /**
  12622. * Update a raw 2D array texture
  12623. * @param texture defines the texture to update
  12624. * @param data defines the data to store
  12625. * @param format defines the data format
  12626. * @param invertY defines if data must be stored with Y axis inverted
  12627. */
  12628. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12629. /**
  12630. * Update a raw 2D array texture
  12631. * @param texture defines the texture to update
  12632. * @param data defines the data to store
  12633. * @param format defines the data format
  12634. * @param invertY defines if data must be stored with Y axis inverted
  12635. * @param compression defines the used compression (can be null)
  12636. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12637. */
  12638. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12639. }
  12640. }
  12641. declare module BABYLON {
  12642. /**
  12643. * Raw texture can help creating a texture directly from an array of data.
  12644. * This can be super useful if you either get the data from an uncompressed source or
  12645. * if you wish to create your texture pixel by pixel.
  12646. */
  12647. export class RawTexture extends Texture {
  12648. /**
  12649. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12650. */
  12651. format: number;
  12652. private _engine;
  12653. /**
  12654. * Instantiates a new RawTexture.
  12655. * Raw texture can help creating a texture directly from an array of data.
  12656. * This can be super useful if you either get the data from an uncompressed source or
  12657. * if you wish to create your texture pixel by pixel.
  12658. * @param data define the array of data to use to create the texture
  12659. * @param width define the width of the texture
  12660. * @param height define the height of the texture
  12661. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12662. * @param scene define the scene the texture belongs to
  12663. * @param generateMipMaps define whether mip maps should be generated or not
  12664. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12665. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12666. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12667. */
  12668. constructor(data: ArrayBufferView, width: number, height: number,
  12669. /**
  12670. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12671. */
  12672. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12673. /**
  12674. * Updates the texture underlying data.
  12675. * @param data Define the new data of the texture
  12676. */
  12677. update(data: ArrayBufferView): void;
  12678. /**
  12679. * Creates a luminance texture from some data.
  12680. * @param data Define the texture data
  12681. * @param width Define the width of the texture
  12682. * @param height Define the height of the texture
  12683. * @param scene Define the scene the texture belongs to
  12684. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12685. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12686. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12687. * @returns the luminance texture
  12688. */
  12689. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12690. /**
  12691. * Creates a luminance alpha texture from some data.
  12692. * @param data Define the texture data
  12693. * @param width Define the width of the texture
  12694. * @param height Define the height of the texture
  12695. * @param scene Define the scene the texture belongs to
  12696. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12697. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12698. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12699. * @returns the luminance alpha texture
  12700. */
  12701. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12702. /**
  12703. * Creates an alpha texture from some data.
  12704. * @param data Define the texture data
  12705. * @param width Define the width of the texture
  12706. * @param height Define the height of the texture
  12707. * @param scene Define the scene the texture belongs to
  12708. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12709. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12710. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12711. * @returns the alpha texture
  12712. */
  12713. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12714. /**
  12715. * Creates a RGB texture from some data.
  12716. * @param data Define the texture data
  12717. * @param width Define the width of the texture
  12718. * @param height Define the height of the texture
  12719. * @param scene Define the scene the texture belongs to
  12720. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12721. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12722. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12723. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12724. * @returns the RGB alpha texture
  12725. */
  12726. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12727. /**
  12728. * Creates a RGBA texture from some data.
  12729. * @param data Define the texture data
  12730. * @param width Define the width of the texture
  12731. * @param height Define the height of the texture
  12732. * @param scene Define the scene the texture belongs to
  12733. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12734. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12735. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12736. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12737. * @returns the RGBA texture
  12738. */
  12739. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12740. /**
  12741. * Creates a R texture from some data.
  12742. * @param data Define the texture data
  12743. * @param width Define the width of the texture
  12744. * @param height Define the height of the texture
  12745. * @param scene Define the scene the texture belongs to
  12746. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12747. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12748. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12749. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12750. * @returns the R texture
  12751. */
  12752. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12753. }
  12754. }
  12755. declare module BABYLON {
  12756. /**
  12757. * Interface for the size containing width and height
  12758. */
  12759. export interface ISize {
  12760. /**
  12761. * Width
  12762. */
  12763. width: number;
  12764. /**
  12765. * Heighht
  12766. */
  12767. height: number;
  12768. }
  12769. /**
  12770. * Size containing widht and height
  12771. */
  12772. export class Size implements ISize {
  12773. /**
  12774. * Width
  12775. */
  12776. width: number;
  12777. /**
  12778. * Height
  12779. */
  12780. height: number;
  12781. /**
  12782. * Creates a Size object from the given width and height (floats).
  12783. * @param width width of the new size
  12784. * @param height height of the new size
  12785. */
  12786. constructor(width: number, height: number);
  12787. /**
  12788. * Returns a string with the Size width and height
  12789. * @returns a string with the Size width and height
  12790. */
  12791. toString(): string;
  12792. /**
  12793. * "Size"
  12794. * @returns the string "Size"
  12795. */
  12796. getClassName(): string;
  12797. /**
  12798. * Returns the Size hash code.
  12799. * @returns a hash code for a unique width and height
  12800. */
  12801. getHashCode(): number;
  12802. /**
  12803. * Updates the current size from the given one.
  12804. * @param src the given size
  12805. */
  12806. copyFrom(src: Size): void;
  12807. /**
  12808. * Updates in place the current Size from the given floats.
  12809. * @param width width of the new size
  12810. * @param height height of the new size
  12811. * @returns the updated Size.
  12812. */
  12813. copyFromFloats(width: number, height: number): Size;
  12814. /**
  12815. * Updates in place the current Size from the given floats.
  12816. * @param width width to set
  12817. * @param height height to set
  12818. * @returns the updated Size.
  12819. */
  12820. set(width: number, height: number): Size;
  12821. /**
  12822. * Multiplies the width and height by numbers
  12823. * @param w factor to multiple the width by
  12824. * @param h factor to multiple the height by
  12825. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12826. */
  12827. multiplyByFloats(w: number, h: number): Size;
  12828. /**
  12829. * Clones the size
  12830. * @returns a new Size copied from the given one.
  12831. */
  12832. clone(): Size;
  12833. /**
  12834. * True if the current Size and the given one width and height are strictly equal.
  12835. * @param other the other size to compare against
  12836. * @returns True if the current Size and the given one width and height are strictly equal.
  12837. */
  12838. equals(other: Size): boolean;
  12839. /**
  12840. * The surface of the Size : width * height (float).
  12841. */
  12842. readonly surface: number;
  12843. /**
  12844. * Create a new size of zero
  12845. * @returns a new Size set to (0.0, 0.0)
  12846. */
  12847. static Zero(): Size;
  12848. /**
  12849. * Sums the width and height of two sizes
  12850. * @param otherSize size to add to this size
  12851. * @returns a new Size set as the addition result of the current Size and the given one.
  12852. */
  12853. add(otherSize: Size): Size;
  12854. /**
  12855. * Subtracts the width and height of two
  12856. * @param otherSize size to subtract to this size
  12857. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12858. */
  12859. subtract(otherSize: Size): Size;
  12860. /**
  12861. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12862. * @param start starting size to lerp between
  12863. * @param end end size to lerp between
  12864. * @param amount amount to lerp between the start and end values
  12865. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12866. */
  12867. static Lerp(start: Size, end: Size, amount: number): Size;
  12868. }
  12869. }
  12870. declare module BABYLON {
  12871. /**
  12872. * Defines a runtime animation
  12873. */
  12874. export class RuntimeAnimation {
  12875. private _events;
  12876. /**
  12877. * The current frame of the runtime animation
  12878. */
  12879. private _currentFrame;
  12880. /**
  12881. * The animation used by the runtime animation
  12882. */
  12883. private _animation;
  12884. /**
  12885. * The target of the runtime animation
  12886. */
  12887. private _target;
  12888. /**
  12889. * The initiating animatable
  12890. */
  12891. private _host;
  12892. /**
  12893. * The original value of the runtime animation
  12894. */
  12895. private _originalValue;
  12896. /**
  12897. * The original blend value of the runtime animation
  12898. */
  12899. private _originalBlendValue;
  12900. /**
  12901. * The offsets cache of the runtime animation
  12902. */
  12903. private _offsetsCache;
  12904. /**
  12905. * The high limits cache of the runtime animation
  12906. */
  12907. private _highLimitsCache;
  12908. /**
  12909. * Specifies if the runtime animation has been stopped
  12910. */
  12911. private _stopped;
  12912. /**
  12913. * The blending factor of the runtime animation
  12914. */
  12915. private _blendingFactor;
  12916. /**
  12917. * The BabylonJS scene
  12918. */
  12919. private _scene;
  12920. /**
  12921. * The current value of the runtime animation
  12922. */
  12923. private _currentValue;
  12924. /** @hidden */
  12925. _animationState: _IAnimationState;
  12926. /**
  12927. * The active target of the runtime animation
  12928. */
  12929. private _activeTargets;
  12930. private _currentActiveTarget;
  12931. private _directTarget;
  12932. /**
  12933. * The target path of the runtime animation
  12934. */
  12935. private _targetPath;
  12936. /**
  12937. * The weight of the runtime animation
  12938. */
  12939. private _weight;
  12940. /**
  12941. * The ratio offset of the runtime animation
  12942. */
  12943. private _ratioOffset;
  12944. /**
  12945. * The previous delay of the runtime animation
  12946. */
  12947. private _previousDelay;
  12948. /**
  12949. * The previous ratio of the runtime animation
  12950. */
  12951. private _previousRatio;
  12952. private _enableBlending;
  12953. private _keys;
  12954. private _minFrame;
  12955. private _maxFrame;
  12956. private _minValue;
  12957. private _maxValue;
  12958. private _targetIsArray;
  12959. /**
  12960. * Gets the current frame of the runtime animation
  12961. */
  12962. readonly currentFrame: number;
  12963. /**
  12964. * Gets the weight of the runtime animation
  12965. */
  12966. readonly weight: number;
  12967. /**
  12968. * Gets the current value of the runtime animation
  12969. */
  12970. readonly currentValue: any;
  12971. /**
  12972. * Gets the target path of the runtime animation
  12973. */
  12974. readonly targetPath: string;
  12975. /**
  12976. * Gets the actual target of the runtime animation
  12977. */
  12978. readonly target: any;
  12979. /** @hidden */
  12980. _onLoop: () => void;
  12981. /**
  12982. * Create a new RuntimeAnimation object
  12983. * @param target defines the target of the animation
  12984. * @param animation defines the source animation object
  12985. * @param scene defines the hosting scene
  12986. * @param host defines the initiating Animatable
  12987. */
  12988. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12989. private _preparePath;
  12990. /**
  12991. * Gets the animation from the runtime animation
  12992. */
  12993. readonly animation: Animation;
  12994. /**
  12995. * Resets the runtime animation to the beginning
  12996. * @param restoreOriginal defines whether to restore the target property to the original value
  12997. */
  12998. reset(restoreOriginal?: boolean): void;
  12999. /**
  13000. * Specifies if the runtime animation is stopped
  13001. * @returns Boolean specifying if the runtime animation is stopped
  13002. */
  13003. isStopped(): boolean;
  13004. /**
  13005. * Disposes of the runtime animation
  13006. */
  13007. dispose(): void;
  13008. /**
  13009. * Apply the interpolated value to the target
  13010. * @param currentValue defines the value computed by the animation
  13011. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13012. */
  13013. setValue(currentValue: any, weight: number): void;
  13014. private _getOriginalValues;
  13015. private _setValue;
  13016. /**
  13017. * Gets the loop pmode of the runtime animation
  13018. * @returns Loop Mode
  13019. */
  13020. private _getCorrectLoopMode;
  13021. /**
  13022. * Move the current animation to a given frame
  13023. * @param frame defines the frame to move to
  13024. */
  13025. goToFrame(frame: number): void;
  13026. /**
  13027. * @hidden Internal use only
  13028. */
  13029. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13030. /**
  13031. * Execute the current animation
  13032. * @param delay defines the delay to add to the current frame
  13033. * @param from defines the lower bound of the animation range
  13034. * @param to defines the upper bound of the animation range
  13035. * @param loop defines if the current animation must loop
  13036. * @param speedRatio defines the current speed ratio
  13037. * @param weight defines the weight of the animation (default is -1 so no weight)
  13038. * @param onLoop optional callback called when animation loops
  13039. * @returns a boolean indicating if the animation is running
  13040. */
  13041. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13042. }
  13043. }
  13044. declare module BABYLON {
  13045. /**
  13046. * Class used to store an actual running animation
  13047. */
  13048. export class Animatable {
  13049. /** defines the target object */
  13050. target: any;
  13051. /** defines the starting frame number (default is 0) */
  13052. fromFrame: number;
  13053. /** defines the ending frame number (default is 100) */
  13054. toFrame: number;
  13055. /** defines if the animation must loop (default is false) */
  13056. loopAnimation: boolean;
  13057. /** defines a callback to call when animation ends if it is not looping */
  13058. onAnimationEnd?: (() => void) | null | undefined;
  13059. /** defines a callback to call when animation loops */
  13060. onAnimationLoop?: (() => void) | null | undefined;
  13061. private _localDelayOffset;
  13062. private _pausedDelay;
  13063. private _runtimeAnimations;
  13064. private _paused;
  13065. private _scene;
  13066. private _speedRatio;
  13067. private _weight;
  13068. private _syncRoot;
  13069. /**
  13070. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13071. * This will only apply for non looping animation (default is true)
  13072. */
  13073. disposeOnEnd: boolean;
  13074. /**
  13075. * Gets a boolean indicating if the animation has started
  13076. */
  13077. animationStarted: boolean;
  13078. /**
  13079. * Observer raised when the animation ends
  13080. */
  13081. onAnimationEndObservable: Observable<Animatable>;
  13082. /**
  13083. * Observer raised when the animation loops
  13084. */
  13085. onAnimationLoopObservable: Observable<Animatable>;
  13086. /**
  13087. * Gets the root Animatable used to synchronize and normalize animations
  13088. */
  13089. readonly syncRoot: Nullable<Animatable>;
  13090. /**
  13091. * Gets the current frame of the first RuntimeAnimation
  13092. * Used to synchronize Animatables
  13093. */
  13094. readonly masterFrame: number;
  13095. /**
  13096. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13097. */
  13098. weight: number;
  13099. /**
  13100. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13101. */
  13102. speedRatio: number;
  13103. /**
  13104. * Creates a new Animatable
  13105. * @param scene defines the hosting scene
  13106. * @param target defines the target object
  13107. * @param fromFrame defines the starting frame number (default is 0)
  13108. * @param toFrame defines the ending frame number (default is 100)
  13109. * @param loopAnimation defines if the animation must loop (default is false)
  13110. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13111. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13112. * @param animations defines a group of animation to add to the new Animatable
  13113. * @param onAnimationLoop defines a callback to call when animation loops
  13114. */
  13115. constructor(scene: Scene,
  13116. /** defines the target object */
  13117. target: any,
  13118. /** defines the starting frame number (default is 0) */
  13119. fromFrame?: number,
  13120. /** defines the ending frame number (default is 100) */
  13121. toFrame?: number,
  13122. /** defines if the animation must loop (default is false) */
  13123. loopAnimation?: boolean, speedRatio?: number,
  13124. /** defines a callback to call when animation ends if it is not looping */
  13125. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13126. /** defines a callback to call when animation loops */
  13127. onAnimationLoop?: (() => void) | null | undefined);
  13128. /**
  13129. * Synchronize and normalize current Animatable with a source Animatable
  13130. * This is useful when using animation weights and when animations are not of the same length
  13131. * @param root defines the root Animatable to synchronize with
  13132. * @returns the current Animatable
  13133. */
  13134. syncWith(root: Animatable): Animatable;
  13135. /**
  13136. * Gets the list of runtime animations
  13137. * @returns an array of RuntimeAnimation
  13138. */
  13139. getAnimations(): RuntimeAnimation[];
  13140. /**
  13141. * Adds more animations to the current animatable
  13142. * @param target defines the target of the animations
  13143. * @param animations defines the new animations to add
  13144. */
  13145. appendAnimations(target: any, animations: Animation[]): void;
  13146. /**
  13147. * Gets the source animation for a specific property
  13148. * @param property defines the propertyu to look for
  13149. * @returns null or the source animation for the given property
  13150. */
  13151. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13152. /**
  13153. * Gets the runtime animation for a specific property
  13154. * @param property defines the propertyu to look for
  13155. * @returns null or the runtime animation for the given property
  13156. */
  13157. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13158. /**
  13159. * Resets the animatable to its original state
  13160. */
  13161. reset(): void;
  13162. /**
  13163. * Allows the animatable to blend with current running animations
  13164. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13165. * @param blendingSpeed defines the blending speed to use
  13166. */
  13167. enableBlending(blendingSpeed: number): void;
  13168. /**
  13169. * Disable animation blending
  13170. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13171. */
  13172. disableBlending(): void;
  13173. /**
  13174. * Jump directly to a given frame
  13175. * @param frame defines the frame to jump to
  13176. */
  13177. goToFrame(frame: number): void;
  13178. /**
  13179. * Pause the animation
  13180. */
  13181. pause(): void;
  13182. /**
  13183. * Restart the animation
  13184. */
  13185. restart(): void;
  13186. private _raiseOnAnimationEnd;
  13187. /**
  13188. * Stop and delete the current animation
  13189. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13190. * @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)
  13191. */
  13192. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13193. /**
  13194. * Wait asynchronously for the animation to end
  13195. * @returns a promise which will be fullfilled when the animation ends
  13196. */
  13197. waitAsync(): Promise<Animatable>;
  13198. /** @hidden */
  13199. _animate(delay: number): boolean;
  13200. }
  13201. interface Scene {
  13202. /** @hidden */
  13203. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13204. /** @hidden */
  13205. _processLateAnimationBindingsForMatrices(holder: {
  13206. totalWeight: number;
  13207. animations: RuntimeAnimation[];
  13208. originalValue: Matrix;
  13209. }): any;
  13210. /** @hidden */
  13211. _processLateAnimationBindingsForQuaternions(holder: {
  13212. totalWeight: number;
  13213. animations: RuntimeAnimation[];
  13214. originalValue: Quaternion;
  13215. }, refQuaternion: Quaternion): Quaternion;
  13216. /** @hidden */
  13217. _processLateAnimationBindings(): void;
  13218. /**
  13219. * Will start the animation sequence of a given target
  13220. * @param target defines the target
  13221. * @param from defines from which frame should animation start
  13222. * @param to defines until which frame should animation run.
  13223. * @param weight defines the weight to apply to the animation (1.0 by default)
  13224. * @param loop defines if the animation loops
  13225. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13226. * @param onAnimationEnd defines the function to be executed when the animation ends
  13227. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13228. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13229. * @param onAnimationLoop defines the callback to call when an animation loops
  13230. * @returns the animatable object created for this animation
  13231. */
  13232. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13233. /**
  13234. * Will start the animation sequence of a given target
  13235. * @param target defines the target
  13236. * @param from defines from which frame should animation start
  13237. * @param to defines until which frame should animation run.
  13238. * @param loop defines if the animation loops
  13239. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13240. * @param onAnimationEnd defines the function to be executed when the animation ends
  13241. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13242. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13243. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13244. * @param onAnimationLoop defines the callback to call when an animation loops
  13245. * @returns the animatable object created for this animation
  13246. */
  13247. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13248. /**
  13249. * Will start the animation sequence of a given target and its hierarchy
  13250. * @param target defines the target
  13251. * @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.
  13252. * @param from defines from which frame should animation start
  13253. * @param to defines until which frame should animation run.
  13254. * @param loop defines if the animation loops
  13255. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13256. * @param onAnimationEnd defines the function to be executed when the animation ends
  13257. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13258. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13259. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13260. * @param onAnimationLoop defines the callback to call when an animation loops
  13261. * @returns the list of created animatables
  13262. */
  13263. 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[];
  13264. /**
  13265. * Begin a new animation on a given node
  13266. * @param target defines the target where the animation will take place
  13267. * @param animations defines the list of animations to start
  13268. * @param from defines the initial value
  13269. * @param to defines the final value
  13270. * @param loop defines if you want animation to loop (off by default)
  13271. * @param speedRatio defines the speed ratio to apply to all animations
  13272. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13273. * @param onAnimationLoop defines the callback to call when an animation loops
  13274. * @returns the list of created animatables
  13275. */
  13276. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13277. /**
  13278. * Begin a new animation on a given node and its hierarchy
  13279. * @param target defines the root node where the animation will take place
  13280. * @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.
  13281. * @param animations defines the list of animations to start
  13282. * @param from defines the initial value
  13283. * @param to defines the final value
  13284. * @param loop defines if you want animation to loop (off by default)
  13285. * @param speedRatio defines the speed ratio to apply to all animations
  13286. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13287. * @param onAnimationLoop defines the callback to call when an animation loops
  13288. * @returns the list of animatables created for all nodes
  13289. */
  13290. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13291. /**
  13292. * Gets the animatable associated with a specific target
  13293. * @param target defines the target of the animatable
  13294. * @returns the required animatable if found
  13295. */
  13296. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13297. /**
  13298. * Gets all animatables associated with a given target
  13299. * @param target defines the target to look animatables for
  13300. * @returns an array of Animatables
  13301. */
  13302. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13303. /**
  13304. * Stops and removes all animations that have been applied to the scene
  13305. */
  13306. stopAllAnimations(): void;
  13307. /**
  13308. * Gets the current delta time used by animation engine
  13309. */
  13310. deltaTime: number;
  13311. }
  13312. interface Bone {
  13313. /**
  13314. * Copy an animation range from another bone
  13315. * @param source defines the source bone
  13316. * @param rangeName defines the range name to copy
  13317. * @param frameOffset defines the frame offset
  13318. * @param rescaleAsRequired defines if rescaling must be applied if required
  13319. * @param skelDimensionsRatio defines the scaling ratio
  13320. * @returns true if operation was successful
  13321. */
  13322. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13323. }
  13324. }
  13325. declare module BABYLON {
  13326. /**
  13327. * Class used to override all child animations of a given target
  13328. */
  13329. export class AnimationPropertiesOverride {
  13330. /**
  13331. * Gets or sets a value indicating if animation blending must be used
  13332. */
  13333. enableBlending: boolean;
  13334. /**
  13335. * Gets or sets the blending speed to use when enableBlending is true
  13336. */
  13337. blendingSpeed: number;
  13338. /**
  13339. * Gets or sets the default loop mode to use
  13340. */
  13341. loopMode: number;
  13342. }
  13343. }
  13344. declare module BABYLON {
  13345. /**
  13346. * Class used to handle skinning animations
  13347. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13348. */
  13349. export class Skeleton implements IAnimatable {
  13350. /** defines the skeleton name */
  13351. name: string;
  13352. /** defines the skeleton Id */
  13353. id: string;
  13354. /**
  13355. * Defines the list of child bones
  13356. */
  13357. bones: Bone[];
  13358. /**
  13359. * Defines an estimate of the dimension of the skeleton at rest
  13360. */
  13361. dimensionsAtRest: Vector3;
  13362. /**
  13363. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13364. */
  13365. needInitialSkinMatrix: boolean;
  13366. /**
  13367. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13368. */
  13369. overrideMesh: Nullable<AbstractMesh>;
  13370. /**
  13371. * Gets the list of animations attached to this skeleton
  13372. */
  13373. animations: Array<Animation>;
  13374. private _scene;
  13375. private _isDirty;
  13376. private _transformMatrices;
  13377. private _transformMatrixTexture;
  13378. private _meshesWithPoseMatrix;
  13379. private _animatables;
  13380. private _identity;
  13381. private _synchronizedWithMesh;
  13382. private _ranges;
  13383. private _lastAbsoluteTransformsUpdateId;
  13384. private _canUseTextureForBones;
  13385. private _uniqueId;
  13386. /** @hidden */
  13387. _numBonesWithLinkedTransformNode: number;
  13388. /** @hidden */
  13389. _hasWaitingData: Nullable<boolean>;
  13390. /**
  13391. * Specifies if the skeleton should be serialized
  13392. */
  13393. doNotSerialize: boolean;
  13394. private _useTextureToStoreBoneMatrices;
  13395. /**
  13396. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13397. * Please note that this option is not available if the hardware does not support it
  13398. */
  13399. useTextureToStoreBoneMatrices: boolean;
  13400. private _animationPropertiesOverride;
  13401. /**
  13402. * Gets or sets the animation properties override
  13403. */
  13404. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13405. /**
  13406. * List of inspectable custom properties (used by the Inspector)
  13407. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13408. */
  13409. inspectableCustomProperties: IInspectable[];
  13410. /**
  13411. * An observable triggered before computing the skeleton's matrices
  13412. */
  13413. onBeforeComputeObservable: Observable<Skeleton>;
  13414. /**
  13415. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13416. */
  13417. readonly isUsingTextureForMatrices: boolean;
  13418. /**
  13419. * Gets the unique ID of this skeleton
  13420. */
  13421. readonly uniqueId: number;
  13422. /**
  13423. * Creates a new skeleton
  13424. * @param name defines the skeleton name
  13425. * @param id defines the skeleton Id
  13426. * @param scene defines the hosting scene
  13427. */
  13428. constructor(
  13429. /** defines the skeleton name */
  13430. name: string,
  13431. /** defines the skeleton Id */
  13432. id: string, scene: Scene);
  13433. /**
  13434. * Gets the current object class name.
  13435. * @return the class name
  13436. */
  13437. getClassName(): string;
  13438. /**
  13439. * Returns an array containing the root bones
  13440. * @returns an array containing the root bones
  13441. */
  13442. getChildren(): Array<Bone>;
  13443. /**
  13444. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13445. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13446. * @returns a Float32Array containing matrices data
  13447. */
  13448. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13449. /**
  13450. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13451. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13452. * @returns a raw texture containing the data
  13453. */
  13454. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13455. /**
  13456. * Gets the current hosting scene
  13457. * @returns a scene object
  13458. */
  13459. getScene(): Scene;
  13460. /**
  13461. * Gets a string representing the current skeleton data
  13462. * @param fullDetails defines a boolean indicating if we want a verbose version
  13463. * @returns a string representing the current skeleton data
  13464. */
  13465. toString(fullDetails?: boolean): string;
  13466. /**
  13467. * Get bone's index searching by name
  13468. * @param name defines bone's name to search for
  13469. * @return the indice of the bone. Returns -1 if not found
  13470. */
  13471. getBoneIndexByName(name: string): number;
  13472. /**
  13473. * Creater a new animation range
  13474. * @param name defines the name of the range
  13475. * @param from defines the start key
  13476. * @param to defines the end key
  13477. */
  13478. createAnimationRange(name: string, from: number, to: number): void;
  13479. /**
  13480. * Delete a specific animation range
  13481. * @param name defines the name of the range
  13482. * @param deleteFrames defines if frames must be removed as well
  13483. */
  13484. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13485. /**
  13486. * Gets a specific animation range
  13487. * @param name defines the name of the range to look for
  13488. * @returns the requested animation range or null if not found
  13489. */
  13490. getAnimationRange(name: string): Nullable<AnimationRange>;
  13491. /**
  13492. * Gets the list of all animation ranges defined on this skeleton
  13493. * @returns an array
  13494. */
  13495. getAnimationRanges(): Nullable<AnimationRange>[];
  13496. /**
  13497. * Copy animation range from a source skeleton.
  13498. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13499. * @param source defines the source skeleton
  13500. * @param name defines the name of the range to copy
  13501. * @param rescaleAsRequired defines if rescaling must be applied if required
  13502. * @returns true if operation was successful
  13503. */
  13504. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13505. /**
  13506. * Forces the skeleton to go to rest pose
  13507. */
  13508. returnToRest(): void;
  13509. private _getHighestAnimationFrame;
  13510. /**
  13511. * Begin a specific animation range
  13512. * @param name defines the name of the range to start
  13513. * @param loop defines if looping must be turned on (false by default)
  13514. * @param speedRatio defines the speed ratio to apply (1 by default)
  13515. * @param onAnimationEnd defines a callback which will be called when animation will end
  13516. * @returns a new animatable
  13517. */
  13518. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13519. /** @hidden */
  13520. _markAsDirty(): void;
  13521. /** @hidden */
  13522. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13523. /** @hidden */
  13524. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13525. private _computeTransformMatrices;
  13526. /**
  13527. * Build all resources required to render a skeleton
  13528. */
  13529. prepare(): void;
  13530. /**
  13531. * Gets the list of animatables currently running for this skeleton
  13532. * @returns an array of animatables
  13533. */
  13534. getAnimatables(): IAnimatable[];
  13535. /**
  13536. * Clone the current skeleton
  13537. * @param name defines the name of the new skeleton
  13538. * @param id defines the id of the new skeleton
  13539. * @returns the new skeleton
  13540. */
  13541. clone(name: string, id?: string): Skeleton;
  13542. /**
  13543. * Enable animation blending for this skeleton
  13544. * @param blendingSpeed defines the blending speed to apply
  13545. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13546. */
  13547. enableBlending(blendingSpeed?: number): void;
  13548. /**
  13549. * Releases all resources associated with the current skeleton
  13550. */
  13551. dispose(): void;
  13552. /**
  13553. * Serialize the skeleton in a JSON object
  13554. * @returns a JSON object
  13555. */
  13556. serialize(): any;
  13557. /**
  13558. * Creates a new skeleton from serialized data
  13559. * @param parsedSkeleton defines the serialized data
  13560. * @param scene defines the hosting scene
  13561. * @returns a new skeleton
  13562. */
  13563. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13564. /**
  13565. * Compute all node absolute transforms
  13566. * @param forceUpdate defines if computation must be done even if cache is up to date
  13567. */
  13568. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13569. /**
  13570. * Gets the root pose matrix
  13571. * @returns a matrix
  13572. */
  13573. getPoseMatrix(): Nullable<Matrix>;
  13574. /**
  13575. * Sorts bones per internal index
  13576. */
  13577. sortBones(): void;
  13578. private _sortBones;
  13579. }
  13580. }
  13581. declare module BABYLON {
  13582. /**
  13583. * Class used to store bone information
  13584. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13585. */
  13586. export class Bone extends Node {
  13587. /**
  13588. * defines the bone name
  13589. */
  13590. name: string;
  13591. private static _tmpVecs;
  13592. private static _tmpQuat;
  13593. private static _tmpMats;
  13594. /**
  13595. * Gets the list of child bones
  13596. */
  13597. children: Bone[];
  13598. /** Gets the animations associated with this bone */
  13599. animations: Animation[];
  13600. /**
  13601. * Gets or sets bone length
  13602. */
  13603. length: number;
  13604. /**
  13605. * @hidden Internal only
  13606. * Set this value to map this bone to a different index in the transform matrices
  13607. * Set this value to -1 to exclude the bone from the transform matrices
  13608. */
  13609. _index: Nullable<number>;
  13610. private _skeleton;
  13611. private _localMatrix;
  13612. private _restPose;
  13613. private _baseMatrix;
  13614. private _absoluteTransform;
  13615. private _invertedAbsoluteTransform;
  13616. private _parent;
  13617. private _scalingDeterminant;
  13618. private _worldTransform;
  13619. private _localScaling;
  13620. private _localRotation;
  13621. private _localPosition;
  13622. private _needToDecompose;
  13623. private _needToCompose;
  13624. /** @hidden */
  13625. _linkedTransformNode: Nullable<TransformNode>;
  13626. /** @hidden */
  13627. _waitingTransformNodeId: Nullable<string>;
  13628. /** @hidden */
  13629. /** @hidden */
  13630. _matrix: Matrix;
  13631. /**
  13632. * Create a new bone
  13633. * @param name defines the bone name
  13634. * @param skeleton defines the parent skeleton
  13635. * @param parentBone defines the parent (can be null if the bone is the root)
  13636. * @param localMatrix defines the local matrix
  13637. * @param restPose defines the rest pose matrix
  13638. * @param baseMatrix defines the base matrix
  13639. * @param index defines index of the bone in the hiearchy
  13640. */
  13641. constructor(
  13642. /**
  13643. * defines the bone name
  13644. */
  13645. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13646. /**
  13647. * Gets the current object class name.
  13648. * @return the class name
  13649. */
  13650. getClassName(): string;
  13651. /**
  13652. * Gets the parent skeleton
  13653. * @returns a skeleton
  13654. */
  13655. getSkeleton(): Skeleton;
  13656. /**
  13657. * Gets parent bone
  13658. * @returns a bone or null if the bone is the root of the bone hierarchy
  13659. */
  13660. getParent(): Nullable<Bone>;
  13661. /**
  13662. * Returns an array containing the root bones
  13663. * @returns an array containing the root bones
  13664. */
  13665. getChildren(): Array<Bone>;
  13666. /**
  13667. * Gets the node index in matrix array generated for rendering
  13668. * @returns the node index
  13669. */
  13670. getIndex(): number;
  13671. /**
  13672. * Sets the parent bone
  13673. * @param parent defines the parent (can be null if the bone is the root)
  13674. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13675. */
  13676. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13677. /**
  13678. * Gets the local matrix
  13679. * @returns a matrix
  13680. */
  13681. getLocalMatrix(): Matrix;
  13682. /**
  13683. * Gets the base matrix (initial matrix which remains unchanged)
  13684. * @returns a matrix
  13685. */
  13686. getBaseMatrix(): Matrix;
  13687. /**
  13688. * Gets the rest pose matrix
  13689. * @returns a matrix
  13690. */
  13691. getRestPose(): Matrix;
  13692. /**
  13693. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13694. */
  13695. getWorldMatrix(): Matrix;
  13696. /**
  13697. * Sets the local matrix to rest pose matrix
  13698. */
  13699. returnToRest(): void;
  13700. /**
  13701. * Gets the inverse of the absolute transform matrix.
  13702. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13703. * @returns a matrix
  13704. */
  13705. getInvertedAbsoluteTransform(): Matrix;
  13706. /**
  13707. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13708. * @returns a matrix
  13709. */
  13710. getAbsoluteTransform(): Matrix;
  13711. /**
  13712. * Links with the given transform node.
  13713. * The local matrix of this bone is copied from the transform node every frame.
  13714. * @param transformNode defines the transform node to link to
  13715. */
  13716. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13717. /**
  13718. * Gets the node used to drive the bone's transformation
  13719. * @returns a transform node or null
  13720. */
  13721. getTransformNode(): Nullable<TransformNode>;
  13722. /** Gets or sets current position (in local space) */
  13723. position: Vector3;
  13724. /** Gets or sets current rotation (in local space) */
  13725. rotation: Vector3;
  13726. /** Gets or sets current rotation quaternion (in local space) */
  13727. rotationQuaternion: Quaternion;
  13728. /** Gets or sets current scaling (in local space) */
  13729. scaling: Vector3;
  13730. /**
  13731. * Gets the animation properties override
  13732. */
  13733. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13734. private _decompose;
  13735. private _compose;
  13736. /**
  13737. * Update the base and local matrices
  13738. * @param matrix defines the new base or local matrix
  13739. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13740. * @param updateLocalMatrix defines if the local matrix should be updated
  13741. */
  13742. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13743. /** @hidden */
  13744. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13745. /**
  13746. * Flag the bone as dirty (Forcing it to update everything)
  13747. */
  13748. markAsDirty(): void;
  13749. /** @hidden */
  13750. _markAsDirtyAndCompose(): void;
  13751. private _markAsDirtyAndDecompose;
  13752. /**
  13753. * Translate the bone in local or world space
  13754. * @param vec The amount to translate the bone
  13755. * @param space The space that the translation is in
  13756. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13757. */
  13758. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13759. /**
  13760. * Set the postion of the bone in local or world space
  13761. * @param position The position to set the bone
  13762. * @param space The space that the position is in
  13763. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13764. */
  13765. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13766. /**
  13767. * Set the absolute position of the bone (world space)
  13768. * @param position The position to set the bone
  13769. * @param mesh The mesh that this bone is attached to
  13770. */
  13771. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13772. /**
  13773. * Scale the bone on the x, y and z axes (in local space)
  13774. * @param x The amount to scale the bone on the x axis
  13775. * @param y The amount to scale the bone on the y axis
  13776. * @param z The amount to scale the bone on the z axis
  13777. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13778. */
  13779. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13780. /**
  13781. * Set the bone scaling in local space
  13782. * @param scale defines the scaling vector
  13783. */
  13784. setScale(scale: Vector3): void;
  13785. /**
  13786. * Gets the current scaling in local space
  13787. * @returns the current scaling vector
  13788. */
  13789. getScale(): Vector3;
  13790. /**
  13791. * Gets the current scaling in local space and stores it in a target vector
  13792. * @param result defines the target vector
  13793. */
  13794. getScaleToRef(result: Vector3): void;
  13795. /**
  13796. * Set the yaw, pitch, and roll of the bone in local or world space
  13797. * @param yaw The rotation of the bone on the y axis
  13798. * @param pitch The rotation of the bone on the x axis
  13799. * @param roll The rotation of the bone on the z axis
  13800. * @param space The space that the axes of rotation are in
  13801. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13802. */
  13803. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13804. /**
  13805. * Add a rotation to the bone on an axis in local or world space
  13806. * @param axis The axis to rotate the bone on
  13807. * @param amount The amount to rotate the bone
  13808. * @param space The space that the axis is in
  13809. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13810. */
  13811. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13812. /**
  13813. * Set the rotation of the bone to a particular axis angle in local or world space
  13814. * @param axis The axis to rotate the bone on
  13815. * @param angle The angle that the bone should be rotated to
  13816. * @param space The space that the axis is in
  13817. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13818. */
  13819. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13820. /**
  13821. * Set the euler rotation of the bone in local of world space
  13822. * @param rotation The euler rotation that the bone should be set to
  13823. * @param space The space that the rotation is in
  13824. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13825. */
  13826. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13827. /**
  13828. * Set the quaternion rotation of the bone in local of world space
  13829. * @param quat The quaternion rotation that the bone should be set to
  13830. * @param space The space that the rotation is in
  13831. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13832. */
  13833. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13834. /**
  13835. * Set the rotation matrix of the bone in local of world space
  13836. * @param rotMat The rotation matrix that the bone should be set to
  13837. * @param space The space that the rotation is in
  13838. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13839. */
  13840. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13841. private _rotateWithMatrix;
  13842. private _getNegativeRotationToRef;
  13843. /**
  13844. * Get the position of the bone in local or world space
  13845. * @param space The space that the returned position is in
  13846. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13847. * @returns The position of the bone
  13848. */
  13849. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13850. /**
  13851. * Copy the position of the bone to a vector3 in local or world space
  13852. * @param space The space that the returned position is in
  13853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13854. * @param result The vector3 to copy the position to
  13855. */
  13856. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13857. /**
  13858. * Get the absolute position of the bone (world space)
  13859. * @param mesh The mesh that this bone is attached to
  13860. * @returns The absolute position of the bone
  13861. */
  13862. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13863. /**
  13864. * Copy the absolute position of the bone (world space) to the result param
  13865. * @param mesh The mesh that this bone is attached to
  13866. * @param result The vector3 to copy the absolute position to
  13867. */
  13868. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13869. /**
  13870. * Compute the absolute transforms of this bone and its children
  13871. */
  13872. computeAbsoluteTransforms(): void;
  13873. /**
  13874. * Get the world direction from an axis that is in the local space of the bone
  13875. * @param localAxis The local direction that is used to compute the world direction
  13876. * @param mesh The mesh that this bone is attached to
  13877. * @returns The world direction
  13878. */
  13879. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13880. /**
  13881. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13882. * @param localAxis The local direction that is used to compute the world direction
  13883. * @param mesh The mesh that this bone is attached to
  13884. * @param result The vector3 that the world direction will be copied to
  13885. */
  13886. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13887. /**
  13888. * Get the euler rotation of the bone in local or world space
  13889. * @param space The space that the rotation should be in
  13890. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13891. * @returns The euler rotation
  13892. */
  13893. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13894. /**
  13895. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13896. * @param space The space that the rotation should be in
  13897. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13898. * @param result The vector3 that the rotation should be copied to
  13899. */
  13900. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13901. /**
  13902. * Get the quaternion rotation of the bone in either local or world space
  13903. * @param space The space that the rotation should be in
  13904. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13905. * @returns The quaternion rotation
  13906. */
  13907. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13908. /**
  13909. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13910. * @param space The space that the rotation should be in
  13911. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13912. * @param result The quaternion that the rotation should be copied to
  13913. */
  13914. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13915. /**
  13916. * Get the rotation matrix of the bone in local or world space
  13917. * @param space The space that the rotation should be in
  13918. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13919. * @returns The rotation matrix
  13920. */
  13921. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13922. /**
  13923. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13924. * @param space The space that the rotation should be in
  13925. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13926. * @param result The quaternion that the rotation should be copied to
  13927. */
  13928. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13929. /**
  13930. * Get the world position of a point that is in the local space of the bone
  13931. * @param position The local position
  13932. * @param mesh The mesh that this bone is attached to
  13933. * @returns The world position
  13934. */
  13935. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13936. /**
  13937. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13938. * @param position The local position
  13939. * @param mesh The mesh that this bone is attached to
  13940. * @param result The vector3 that the world position should be copied to
  13941. */
  13942. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13943. /**
  13944. * Get the local position of a point that is in world space
  13945. * @param position The world position
  13946. * @param mesh The mesh that this bone is attached to
  13947. * @returns The local position
  13948. */
  13949. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13950. /**
  13951. * Get the local position of a point that is in world space and copy it to the result param
  13952. * @param position The world position
  13953. * @param mesh The mesh that this bone is attached to
  13954. * @param result The vector3 that the local position should be copied to
  13955. */
  13956. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13957. }
  13958. }
  13959. declare module BABYLON {
  13960. /**
  13961. * 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.
  13962. * @see https://doc.babylonjs.com/how_to/transformnode
  13963. */
  13964. export class TransformNode extends Node {
  13965. /**
  13966. * Object will not rotate to face the camera
  13967. */
  13968. static BILLBOARDMODE_NONE: number;
  13969. /**
  13970. * Object will rotate to face the camera but only on the x axis
  13971. */
  13972. static BILLBOARDMODE_X: number;
  13973. /**
  13974. * Object will rotate to face the camera but only on the y axis
  13975. */
  13976. static BILLBOARDMODE_Y: number;
  13977. /**
  13978. * Object will rotate to face the camera but only on the z axis
  13979. */
  13980. static BILLBOARDMODE_Z: number;
  13981. /**
  13982. * Object will rotate to face the camera
  13983. */
  13984. static BILLBOARDMODE_ALL: number;
  13985. /**
  13986. * Object will rotate to face the camera's position instead of orientation
  13987. */
  13988. static BILLBOARDMODE_USE_POSITION: number;
  13989. private _forward;
  13990. private _forwardInverted;
  13991. private _up;
  13992. private _right;
  13993. private _rightInverted;
  13994. private _position;
  13995. private _rotation;
  13996. private _rotationQuaternion;
  13997. protected _scaling: Vector3;
  13998. protected _isDirty: boolean;
  13999. private _transformToBoneReferal;
  14000. private _isAbsoluteSynced;
  14001. private _billboardMode;
  14002. /**
  14003. * Gets or sets the billboard mode. Default is 0.
  14004. *
  14005. * | Value | Type | Description |
  14006. * | --- | --- | --- |
  14007. * | 0 | BILLBOARDMODE_NONE | |
  14008. * | 1 | BILLBOARDMODE_X | |
  14009. * | 2 | BILLBOARDMODE_Y | |
  14010. * | 4 | BILLBOARDMODE_Z | |
  14011. * | 7 | BILLBOARDMODE_ALL | |
  14012. *
  14013. */
  14014. billboardMode: number;
  14015. private _preserveParentRotationForBillboard;
  14016. /**
  14017. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14018. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14019. */
  14020. preserveParentRotationForBillboard: boolean;
  14021. /**
  14022. * 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
  14023. */
  14024. scalingDeterminant: number;
  14025. private _infiniteDistance;
  14026. /**
  14027. * Gets or sets the distance of the object to max, often used by skybox
  14028. */
  14029. infiniteDistance: boolean;
  14030. /**
  14031. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14032. * By default the system will update normals to compensate
  14033. */
  14034. ignoreNonUniformScaling: boolean;
  14035. /**
  14036. * 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
  14037. */
  14038. reIntegrateRotationIntoRotationQuaternion: boolean;
  14039. /** @hidden */
  14040. _poseMatrix: Nullable<Matrix>;
  14041. /** @hidden */
  14042. _localMatrix: Matrix;
  14043. private _usePivotMatrix;
  14044. private _absolutePosition;
  14045. private _absoluteScaling;
  14046. private _absoluteRotationQuaternion;
  14047. private _pivotMatrix;
  14048. private _pivotMatrixInverse;
  14049. protected _postMultiplyPivotMatrix: boolean;
  14050. protected _isWorldMatrixFrozen: boolean;
  14051. /** @hidden */
  14052. _indexInSceneTransformNodesArray: number;
  14053. /**
  14054. * An event triggered after the world matrix is updated
  14055. */
  14056. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14057. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14058. /**
  14059. * Gets a string identifying the name of the class
  14060. * @returns "TransformNode" string
  14061. */
  14062. getClassName(): string;
  14063. /**
  14064. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14065. */
  14066. position: Vector3;
  14067. /**
  14068. * 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)).
  14069. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14070. */
  14071. rotation: Vector3;
  14072. /**
  14073. * 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)).
  14074. */
  14075. scaling: Vector3;
  14076. /**
  14077. * 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).
  14078. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14079. */
  14080. rotationQuaternion: Nullable<Quaternion>;
  14081. /**
  14082. * The forward direction of that transform in world space.
  14083. */
  14084. readonly forward: Vector3;
  14085. /**
  14086. * The up direction of that transform in world space.
  14087. */
  14088. readonly up: Vector3;
  14089. /**
  14090. * The right direction of that transform in world space.
  14091. */
  14092. readonly right: Vector3;
  14093. /**
  14094. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14095. * @param matrix the matrix to copy the pose from
  14096. * @returns this TransformNode.
  14097. */
  14098. updatePoseMatrix(matrix: Matrix): TransformNode;
  14099. /**
  14100. * Returns the mesh Pose matrix.
  14101. * @returns the pose matrix
  14102. */
  14103. getPoseMatrix(): Matrix;
  14104. /** @hidden */
  14105. _isSynchronized(): boolean;
  14106. /** @hidden */
  14107. _initCache(): void;
  14108. /**
  14109. * Flag the transform node as dirty (Forcing it to update everything)
  14110. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14111. * @returns this transform node
  14112. */
  14113. markAsDirty(property: string): TransformNode;
  14114. /**
  14115. * Returns the current mesh absolute position.
  14116. * Returns a Vector3.
  14117. */
  14118. readonly absolutePosition: Vector3;
  14119. /**
  14120. * Returns the current mesh absolute scaling.
  14121. * Returns a Vector3.
  14122. */
  14123. readonly absoluteScaling: Vector3;
  14124. /**
  14125. * Returns the current mesh absolute rotation.
  14126. * Returns a Quaternion.
  14127. */
  14128. readonly absoluteRotationQuaternion: Quaternion;
  14129. /**
  14130. * Sets a new matrix to apply before all other transformation
  14131. * @param matrix defines the transform matrix
  14132. * @returns the current TransformNode
  14133. */
  14134. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14135. /**
  14136. * Sets a new pivot matrix to the current node
  14137. * @param matrix defines the new pivot matrix to use
  14138. * @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
  14139. * @returns the current TransformNode
  14140. */
  14141. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14142. /**
  14143. * Returns the mesh pivot matrix.
  14144. * Default : Identity.
  14145. * @returns the matrix
  14146. */
  14147. getPivotMatrix(): Matrix;
  14148. /**
  14149. * Instantiate (when possible) or clone that node with its hierarchy
  14150. * @param newParent defines the new parent to use for the instance (or clone)
  14151. * @param options defines options to configure how copy is done
  14152. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14153. * @returns an instance (or a clone) of the current node with its hiearchy
  14154. */
  14155. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14156. doNotInstantiate: boolean;
  14157. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14158. /**
  14159. * Prevents the World matrix to be computed any longer
  14160. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14161. * @returns the TransformNode.
  14162. */
  14163. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14164. /**
  14165. * Allows back the World matrix computation.
  14166. * @returns the TransformNode.
  14167. */
  14168. unfreezeWorldMatrix(): this;
  14169. /**
  14170. * True if the World matrix has been frozen.
  14171. */
  14172. readonly isWorldMatrixFrozen: boolean;
  14173. /**
  14174. * Retuns the mesh absolute position in the World.
  14175. * @returns a Vector3.
  14176. */
  14177. getAbsolutePosition(): Vector3;
  14178. /**
  14179. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14180. * @param absolutePosition the absolute position to set
  14181. * @returns the TransformNode.
  14182. */
  14183. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14184. /**
  14185. * Sets the mesh position in its local space.
  14186. * @param vector3 the position to set in localspace
  14187. * @returns the TransformNode.
  14188. */
  14189. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14190. /**
  14191. * Returns the mesh position in the local space from the current World matrix values.
  14192. * @returns a new Vector3.
  14193. */
  14194. getPositionExpressedInLocalSpace(): Vector3;
  14195. /**
  14196. * Translates the mesh along the passed Vector3 in its local space.
  14197. * @param vector3 the distance to translate in localspace
  14198. * @returns the TransformNode.
  14199. */
  14200. locallyTranslate(vector3: Vector3): TransformNode;
  14201. private static _lookAtVectorCache;
  14202. /**
  14203. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14204. * @param targetPoint the position (must be in same space as current mesh) to look at
  14205. * @param yawCor optional yaw (y-axis) correction in radians
  14206. * @param pitchCor optional pitch (x-axis) correction in radians
  14207. * @param rollCor optional roll (z-axis) correction in radians
  14208. * @param space the choosen space of the target
  14209. * @returns the TransformNode.
  14210. */
  14211. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14212. /**
  14213. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14214. * This Vector3 is expressed in the World space.
  14215. * @param localAxis axis to rotate
  14216. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14217. */
  14218. getDirection(localAxis: Vector3): Vector3;
  14219. /**
  14220. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14221. * localAxis is expressed in the mesh local space.
  14222. * result is computed in the Wordl space from the mesh World matrix.
  14223. * @param localAxis axis to rotate
  14224. * @param result the resulting transformnode
  14225. * @returns this TransformNode.
  14226. */
  14227. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14228. /**
  14229. * Sets this transform node rotation to the given local axis.
  14230. * @param localAxis the axis in local space
  14231. * @param yawCor optional yaw (y-axis) correction in radians
  14232. * @param pitchCor optional pitch (x-axis) correction in radians
  14233. * @param rollCor optional roll (z-axis) correction in radians
  14234. * @returns this TransformNode
  14235. */
  14236. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14237. /**
  14238. * Sets a new pivot point to the current node
  14239. * @param point defines the new pivot point to use
  14240. * @param space defines if the point is in world or local space (local by default)
  14241. * @returns the current TransformNode
  14242. */
  14243. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14244. /**
  14245. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14246. * @returns the pivot point
  14247. */
  14248. getPivotPoint(): Vector3;
  14249. /**
  14250. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14251. * @param result the vector3 to store the result
  14252. * @returns this TransformNode.
  14253. */
  14254. getPivotPointToRef(result: Vector3): TransformNode;
  14255. /**
  14256. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14257. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14258. */
  14259. getAbsolutePivotPoint(): Vector3;
  14260. /**
  14261. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14262. * @param result vector3 to store the result
  14263. * @returns this TransformNode.
  14264. */
  14265. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14266. /**
  14267. * Defines the passed node as the parent of the current node.
  14268. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14269. * @see https://doc.babylonjs.com/how_to/parenting
  14270. * @param node the node ot set as the parent
  14271. * @returns this TransformNode.
  14272. */
  14273. setParent(node: Nullable<Node>): TransformNode;
  14274. private _nonUniformScaling;
  14275. /**
  14276. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14277. */
  14278. readonly nonUniformScaling: boolean;
  14279. /** @hidden */
  14280. _updateNonUniformScalingState(value: boolean): boolean;
  14281. /**
  14282. * Attach the current TransformNode to another TransformNode associated with a bone
  14283. * @param bone Bone affecting the TransformNode
  14284. * @param affectedTransformNode TransformNode associated with the bone
  14285. * @returns this object
  14286. */
  14287. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14288. /**
  14289. * Detach the transform node if its associated with a bone
  14290. * @returns this object
  14291. */
  14292. detachFromBone(): TransformNode;
  14293. private static _rotationAxisCache;
  14294. /**
  14295. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14296. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14297. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14298. * The passed axis is also normalized.
  14299. * @param axis the axis to rotate around
  14300. * @param amount the amount to rotate in radians
  14301. * @param space Space to rotate in (Default: local)
  14302. * @returns the TransformNode.
  14303. */
  14304. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14305. /**
  14306. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14307. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14308. * The passed axis is also normalized. .
  14309. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14310. * @param point the point to rotate around
  14311. * @param axis the axis to rotate around
  14312. * @param amount the amount to rotate in radians
  14313. * @returns the TransformNode
  14314. */
  14315. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14316. /**
  14317. * Translates the mesh along the axis vector for the passed distance in the given space.
  14318. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14319. * @param axis the axis to translate in
  14320. * @param distance the distance to translate
  14321. * @param space Space to rotate in (Default: local)
  14322. * @returns the TransformNode.
  14323. */
  14324. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14325. /**
  14326. * Adds a rotation step to the mesh current rotation.
  14327. * x, y, z are Euler angles expressed in radians.
  14328. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14329. * This means this rotation is made in the mesh local space only.
  14330. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14331. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14332. * ```javascript
  14333. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14334. * ```
  14335. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14336. * 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.
  14337. * @param x Rotation to add
  14338. * @param y Rotation to add
  14339. * @param z Rotation to add
  14340. * @returns the TransformNode.
  14341. */
  14342. addRotation(x: number, y: number, z: number): TransformNode;
  14343. /**
  14344. * @hidden
  14345. */
  14346. protected _getEffectiveParent(): Nullable<Node>;
  14347. /**
  14348. * Computes the world matrix of the node
  14349. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14350. * @returns the world matrix
  14351. */
  14352. computeWorldMatrix(force?: boolean): Matrix;
  14353. protected _afterComputeWorldMatrix(): void;
  14354. /**
  14355. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14356. * @param func callback function to add
  14357. *
  14358. * @returns the TransformNode.
  14359. */
  14360. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14361. /**
  14362. * Removes a registered callback function.
  14363. * @param func callback function to remove
  14364. * @returns the TransformNode.
  14365. */
  14366. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14367. /**
  14368. * Gets the position of the current mesh in camera space
  14369. * @param camera defines the camera to use
  14370. * @returns a position
  14371. */
  14372. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14373. /**
  14374. * Returns the distance from the mesh to the active camera
  14375. * @param camera defines the camera to use
  14376. * @returns the distance
  14377. */
  14378. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14379. /**
  14380. * Clone the current transform node
  14381. * @param name Name of the new clone
  14382. * @param newParent New parent for the clone
  14383. * @param doNotCloneChildren Do not clone children hierarchy
  14384. * @returns the new transform node
  14385. */
  14386. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14387. /**
  14388. * Serializes the objects information.
  14389. * @param currentSerializationObject defines the object to serialize in
  14390. * @returns the serialized object
  14391. */
  14392. serialize(currentSerializationObject?: any): any;
  14393. /**
  14394. * Returns a new TransformNode object parsed from the source provided.
  14395. * @param parsedTransformNode is the source.
  14396. * @param scene the scne the object belongs to
  14397. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14398. * @returns a new TransformNode object parsed from the source provided.
  14399. */
  14400. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14401. /**
  14402. * Get all child-transformNodes of this node
  14403. * @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
  14404. * @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
  14405. * @returns an array of TransformNode
  14406. */
  14407. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14408. /**
  14409. * Releases resources associated with this transform node.
  14410. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14411. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14412. */
  14413. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14414. /**
  14415. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14416. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14417. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14418. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14419. * @returns the current mesh
  14420. */
  14421. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14422. private _syncAbsoluteScalingAndRotation;
  14423. }
  14424. }
  14425. declare module BABYLON {
  14426. /**
  14427. * Defines the types of pose enabled controllers that are supported
  14428. */
  14429. export enum PoseEnabledControllerType {
  14430. /**
  14431. * HTC Vive
  14432. */
  14433. VIVE = 0,
  14434. /**
  14435. * Oculus Rift
  14436. */
  14437. OCULUS = 1,
  14438. /**
  14439. * Windows mixed reality
  14440. */
  14441. WINDOWS = 2,
  14442. /**
  14443. * Samsung gear VR
  14444. */
  14445. GEAR_VR = 3,
  14446. /**
  14447. * Google Daydream
  14448. */
  14449. DAYDREAM = 4,
  14450. /**
  14451. * Generic
  14452. */
  14453. GENERIC = 5
  14454. }
  14455. /**
  14456. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14457. */
  14458. export interface MutableGamepadButton {
  14459. /**
  14460. * Value of the button/trigger
  14461. */
  14462. value: number;
  14463. /**
  14464. * If the button/trigger is currently touched
  14465. */
  14466. touched: boolean;
  14467. /**
  14468. * If the button/trigger is currently pressed
  14469. */
  14470. pressed: boolean;
  14471. }
  14472. /**
  14473. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14474. * @hidden
  14475. */
  14476. export interface ExtendedGamepadButton extends GamepadButton {
  14477. /**
  14478. * If the button/trigger is currently pressed
  14479. */
  14480. readonly pressed: boolean;
  14481. /**
  14482. * If the button/trigger is currently touched
  14483. */
  14484. readonly touched: boolean;
  14485. /**
  14486. * Value of the button/trigger
  14487. */
  14488. readonly value: number;
  14489. }
  14490. /** @hidden */
  14491. export interface _GamePadFactory {
  14492. /**
  14493. * Returns wether or not the current gamepad can be created for this type of controller.
  14494. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14495. * @returns true if it can be created, otherwise false
  14496. */
  14497. canCreate(gamepadInfo: any): boolean;
  14498. /**
  14499. * Creates a new instance of the Gamepad.
  14500. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14501. * @returns the new gamepad instance
  14502. */
  14503. create(gamepadInfo: any): Gamepad;
  14504. }
  14505. /**
  14506. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14507. */
  14508. export class PoseEnabledControllerHelper {
  14509. /** @hidden */
  14510. static _ControllerFactories: _GamePadFactory[];
  14511. /** @hidden */
  14512. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14513. /**
  14514. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14515. * @param vrGamepad the gamepad to initialized
  14516. * @returns a vr controller of the type the gamepad identified as
  14517. */
  14518. static InitiateController(vrGamepad: any): Gamepad;
  14519. }
  14520. /**
  14521. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14522. */
  14523. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14524. /**
  14525. * If the controller is used in a webXR session
  14526. */
  14527. isXR: boolean;
  14528. private _deviceRoomPosition;
  14529. private _deviceRoomRotationQuaternion;
  14530. /**
  14531. * The device position in babylon space
  14532. */
  14533. devicePosition: Vector3;
  14534. /**
  14535. * The device rotation in babylon space
  14536. */
  14537. deviceRotationQuaternion: Quaternion;
  14538. /**
  14539. * The scale factor of the device in babylon space
  14540. */
  14541. deviceScaleFactor: number;
  14542. /**
  14543. * (Likely devicePosition should be used instead) The device position in its room space
  14544. */
  14545. position: Vector3;
  14546. /**
  14547. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14548. */
  14549. rotationQuaternion: Quaternion;
  14550. /**
  14551. * The type of controller (Eg. Windows mixed reality)
  14552. */
  14553. controllerType: PoseEnabledControllerType;
  14554. protected _calculatedPosition: Vector3;
  14555. private _calculatedRotation;
  14556. /**
  14557. * The raw pose from the device
  14558. */
  14559. rawPose: DevicePose;
  14560. private _trackPosition;
  14561. private _maxRotationDistFromHeadset;
  14562. private _draggedRoomRotation;
  14563. /**
  14564. * @hidden
  14565. */
  14566. _disableTrackPosition(fixedPosition: Vector3): void;
  14567. /**
  14568. * Internal, the mesh attached to the controller
  14569. * @hidden
  14570. */
  14571. _mesh: Nullable<AbstractMesh>;
  14572. private _poseControlledCamera;
  14573. private _leftHandSystemQuaternion;
  14574. /**
  14575. * Internal, matrix used to convert room space to babylon space
  14576. * @hidden
  14577. */
  14578. _deviceToWorld: Matrix;
  14579. /**
  14580. * Node to be used when casting a ray from the controller
  14581. * @hidden
  14582. */
  14583. _pointingPoseNode: Nullable<TransformNode>;
  14584. /**
  14585. * Name of the child mesh that can be used to cast a ray from the controller
  14586. */
  14587. static readonly POINTING_POSE: string;
  14588. /**
  14589. * Creates a new PoseEnabledController from a gamepad
  14590. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14591. */
  14592. constructor(browserGamepad: any);
  14593. private _workingMatrix;
  14594. /**
  14595. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14596. */
  14597. update(): void;
  14598. /**
  14599. * Updates only the pose device and mesh without doing any button event checking
  14600. */
  14601. protected _updatePoseAndMesh(): void;
  14602. /**
  14603. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14604. * @param poseData raw pose fromthe device
  14605. */
  14606. updateFromDevice(poseData: DevicePose): void;
  14607. /**
  14608. * @hidden
  14609. */
  14610. _meshAttachedObservable: Observable<AbstractMesh>;
  14611. /**
  14612. * Attaches a mesh to the controller
  14613. * @param mesh the mesh to be attached
  14614. */
  14615. attachToMesh(mesh: AbstractMesh): void;
  14616. /**
  14617. * Attaches the controllers mesh to a camera
  14618. * @param camera the camera the mesh should be attached to
  14619. */
  14620. attachToPoseControlledCamera(camera: TargetCamera): void;
  14621. /**
  14622. * Disposes of the controller
  14623. */
  14624. dispose(): void;
  14625. /**
  14626. * The mesh that is attached to the controller
  14627. */
  14628. readonly mesh: Nullable<AbstractMesh>;
  14629. /**
  14630. * Gets the ray of the controller in the direction the controller is pointing
  14631. * @param length the length the resulting ray should be
  14632. * @returns a ray in the direction the controller is pointing
  14633. */
  14634. getForwardRay(length?: number): Ray;
  14635. }
  14636. }
  14637. declare module BABYLON {
  14638. /**
  14639. * Defines the WebVRController object that represents controllers tracked in 3D space
  14640. */
  14641. export abstract class WebVRController extends PoseEnabledController {
  14642. /**
  14643. * Internal, the default controller model for the controller
  14644. */
  14645. protected _defaultModel: Nullable<AbstractMesh>;
  14646. /**
  14647. * Fired when the trigger state has changed
  14648. */
  14649. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14650. /**
  14651. * Fired when the main button state has changed
  14652. */
  14653. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14654. /**
  14655. * Fired when the secondary button state has changed
  14656. */
  14657. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14658. /**
  14659. * Fired when the pad state has changed
  14660. */
  14661. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14662. /**
  14663. * Fired when controllers stick values have changed
  14664. */
  14665. onPadValuesChangedObservable: Observable<StickValues>;
  14666. /**
  14667. * Array of button availible on the controller
  14668. */
  14669. protected _buttons: Array<MutableGamepadButton>;
  14670. private _onButtonStateChange;
  14671. /**
  14672. * Fired when a controller button's state has changed
  14673. * @param callback the callback containing the button that was modified
  14674. */
  14675. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14676. /**
  14677. * X and Y axis corresponding to the controllers joystick
  14678. */
  14679. pad: StickValues;
  14680. /**
  14681. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14682. */
  14683. hand: string;
  14684. /**
  14685. * The default controller model for the controller
  14686. */
  14687. readonly defaultModel: Nullable<AbstractMesh>;
  14688. /**
  14689. * Creates a new WebVRController from a gamepad
  14690. * @param vrGamepad the gamepad that the WebVRController should be created from
  14691. */
  14692. constructor(vrGamepad: any);
  14693. /**
  14694. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14695. */
  14696. update(): void;
  14697. /**
  14698. * Function to be called when a button is modified
  14699. */
  14700. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14701. /**
  14702. * Loads a mesh and attaches it to the controller
  14703. * @param scene the scene the mesh should be added to
  14704. * @param meshLoaded callback for when the mesh has been loaded
  14705. */
  14706. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14707. private _setButtonValue;
  14708. private _changes;
  14709. private _checkChanges;
  14710. /**
  14711. * Disposes of th webVRCOntroller
  14712. */
  14713. dispose(): void;
  14714. }
  14715. }
  14716. declare module BABYLON {
  14717. /**
  14718. * The HemisphericLight simulates the ambient environment light,
  14719. * so the passed direction is the light reflection direction, not the incoming direction.
  14720. */
  14721. export class HemisphericLight extends Light {
  14722. /**
  14723. * The groundColor is the light in the opposite direction to the one specified during creation.
  14724. * 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.
  14725. */
  14726. groundColor: Color3;
  14727. /**
  14728. * The light reflection direction, not the incoming direction.
  14729. */
  14730. direction: Vector3;
  14731. /**
  14732. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14733. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14734. * The HemisphericLight can't cast shadows.
  14735. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14736. * @param name The friendly name of the light
  14737. * @param direction The direction of the light reflection
  14738. * @param scene The scene the light belongs to
  14739. */
  14740. constructor(name: string, direction: Vector3, scene: Scene);
  14741. protected _buildUniformLayout(): void;
  14742. /**
  14743. * Returns the string "HemisphericLight".
  14744. * @return The class name
  14745. */
  14746. getClassName(): string;
  14747. /**
  14748. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14749. * Returns the updated direction.
  14750. * @param target The target the direction should point to
  14751. * @return The computed direction
  14752. */
  14753. setDirectionToTarget(target: Vector3): Vector3;
  14754. /**
  14755. * Returns the shadow generator associated to the light.
  14756. * @returns Always null for hemispheric lights because it does not support shadows.
  14757. */
  14758. getShadowGenerator(): Nullable<IShadowGenerator>;
  14759. /**
  14760. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14761. * @param effect The effect to update
  14762. * @param lightIndex The index of the light in the effect to update
  14763. * @returns The hemispheric light
  14764. */
  14765. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14766. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14767. /**
  14768. * Computes the world matrix of the node
  14769. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14770. * @param useWasUpdatedFlag defines a reserved property
  14771. * @returns the world matrix
  14772. */
  14773. computeWorldMatrix(): Matrix;
  14774. /**
  14775. * Returns the integer 3.
  14776. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14777. */
  14778. getTypeID(): number;
  14779. /**
  14780. * Prepares the list of defines specific to the light type.
  14781. * @param defines the list of defines
  14782. * @param lightIndex defines the index of the light for the effect
  14783. */
  14784. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14785. }
  14786. }
  14787. declare module BABYLON {
  14788. /** @hidden */
  14789. export var vrMultiviewToSingleviewPixelShader: {
  14790. name: string;
  14791. shader: string;
  14792. };
  14793. }
  14794. declare module BABYLON {
  14795. /**
  14796. * Renders to multiple views with a single draw call
  14797. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14798. */
  14799. export class MultiviewRenderTarget extends RenderTargetTexture {
  14800. /**
  14801. * Creates a multiview render target
  14802. * @param scene scene used with the render target
  14803. * @param size the size of the render target (used for each view)
  14804. */
  14805. constructor(scene: Scene, size?: number | {
  14806. width: number;
  14807. height: number;
  14808. } | {
  14809. ratio: number;
  14810. });
  14811. /**
  14812. * @hidden
  14813. * @param faceIndex the face index, if its a cube texture
  14814. */
  14815. _bindFrameBuffer(faceIndex?: number): void;
  14816. /**
  14817. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14818. * @returns the view count
  14819. */
  14820. getViewCount(): number;
  14821. }
  14822. }
  14823. declare module BABYLON {
  14824. /**
  14825. * Represents a camera frustum
  14826. */
  14827. export class Frustum {
  14828. /**
  14829. * Gets the planes representing the frustum
  14830. * @param transform matrix to be applied to the returned planes
  14831. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14832. */
  14833. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14834. /**
  14835. * Gets the near frustum plane transformed by the transform matrix
  14836. * @param transform transformation matrix to be applied to the resulting frustum plane
  14837. * @param frustumPlane the resuling frustum plane
  14838. */
  14839. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14840. /**
  14841. * Gets the far frustum plane transformed by the transform matrix
  14842. * @param transform transformation matrix to be applied to the resulting frustum plane
  14843. * @param frustumPlane the resuling frustum plane
  14844. */
  14845. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14846. /**
  14847. * Gets the left frustum plane transformed by the transform matrix
  14848. * @param transform transformation matrix to be applied to the resulting frustum plane
  14849. * @param frustumPlane the resuling frustum plane
  14850. */
  14851. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14852. /**
  14853. * Gets the right frustum plane transformed by the transform matrix
  14854. * @param transform transformation matrix to be applied to the resulting frustum plane
  14855. * @param frustumPlane the resuling frustum plane
  14856. */
  14857. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14858. /**
  14859. * Gets the top frustum plane transformed by the transform matrix
  14860. * @param transform transformation matrix to be applied to the resulting frustum plane
  14861. * @param frustumPlane the resuling frustum plane
  14862. */
  14863. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14864. /**
  14865. * Gets the bottom frustum plane transformed by the transform matrix
  14866. * @param transform transformation matrix to be applied to the resulting frustum plane
  14867. * @param frustumPlane the resuling frustum plane
  14868. */
  14869. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14870. /**
  14871. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14872. * @param transform transformation matrix to be applied to the resulting frustum planes
  14873. * @param frustumPlanes the resuling frustum planes
  14874. */
  14875. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14876. }
  14877. }
  14878. declare module BABYLON {
  14879. interface Engine {
  14880. /**
  14881. * Creates a new multiview render target
  14882. * @param width defines the width of the texture
  14883. * @param height defines the height of the texture
  14884. * @returns the created multiview texture
  14885. */
  14886. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14887. /**
  14888. * Binds a multiview framebuffer to be drawn to
  14889. * @param multiviewTexture texture to bind
  14890. */
  14891. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14892. }
  14893. interface Camera {
  14894. /**
  14895. * @hidden
  14896. * 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)
  14897. */
  14898. _useMultiviewToSingleView: boolean;
  14899. /**
  14900. * @hidden
  14901. * 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)
  14902. */
  14903. _multiviewTexture: Nullable<RenderTargetTexture>;
  14904. /**
  14905. * @hidden
  14906. * ensures the multiview texture of the camera exists and has the specified width/height
  14907. * @param width height to set on the multiview texture
  14908. * @param height width to set on the multiview texture
  14909. */
  14910. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14911. }
  14912. interface Scene {
  14913. /** @hidden */
  14914. _transformMatrixR: Matrix;
  14915. /** @hidden */
  14916. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14917. /** @hidden */
  14918. _createMultiviewUbo(): void;
  14919. /** @hidden */
  14920. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14921. /** @hidden */
  14922. _renderMultiviewToSingleView(camera: Camera): void;
  14923. }
  14924. }
  14925. declare module BABYLON {
  14926. /**
  14927. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14928. * This will not be used for webXR as it supports displaying texture arrays directly
  14929. */
  14930. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14931. /**
  14932. * Initializes a VRMultiviewToSingleview
  14933. * @param name name of the post process
  14934. * @param camera camera to be applied to
  14935. * @param scaleFactor scaling factor to the size of the output texture
  14936. */
  14937. constructor(name: string, camera: Camera, scaleFactor: number);
  14938. }
  14939. }
  14940. declare module BABYLON {
  14941. /**
  14942. * Interface used to define additional presentation attributes
  14943. */
  14944. export interface IVRPresentationAttributes {
  14945. /**
  14946. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  14947. */
  14948. highRefreshRate: boolean;
  14949. /**
  14950. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  14951. */
  14952. foveationLevel: number;
  14953. }
  14954. interface Engine {
  14955. /** @hidden */
  14956. _vrDisplay: any;
  14957. /** @hidden */
  14958. _vrSupported: boolean;
  14959. /** @hidden */
  14960. _oldSize: Size;
  14961. /** @hidden */
  14962. _oldHardwareScaleFactor: number;
  14963. /** @hidden */
  14964. _vrExclusivePointerMode: boolean;
  14965. /** @hidden */
  14966. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14967. /** @hidden */
  14968. _onVRDisplayPointerRestricted: () => void;
  14969. /** @hidden */
  14970. _onVRDisplayPointerUnrestricted: () => void;
  14971. /** @hidden */
  14972. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14973. /** @hidden */
  14974. _onVrDisplayDisconnect: Nullable<() => void>;
  14975. /** @hidden */
  14976. _onVrDisplayPresentChange: Nullable<() => void>;
  14977. /**
  14978. * Observable signaled when VR display mode changes
  14979. */
  14980. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14981. /**
  14982. * Observable signaled when VR request present is complete
  14983. */
  14984. onVRRequestPresentComplete: Observable<boolean>;
  14985. /**
  14986. * Observable signaled when VR request present starts
  14987. */
  14988. onVRRequestPresentStart: Observable<Engine>;
  14989. /**
  14990. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14991. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14992. */
  14993. isInVRExclusivePointerMode: boolean;
  14994. /**
  14995. * Gets a boolean indicating if a webVR device was detected
  14996. * @returns true if a webVR device was detected
  14997. */
  14998. isVRDevicePresent(): boolean;
  14999. /**
  15000. * Gets the current webVR device
  15001. * @returns the current webVR device (or null)
  15002. */
  15003. getVRDevice(): any;
  15004. /**
  15005. * Initializes a webVR display and starts listening to display change events
  15006. * The onVRDisplayChangedObservable will be notified upon these changes
  15007. * @returns A promise containing a VRDisplay and if vr is supported
  15008. */
  15009. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15010. /** @hidden */
  15011. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15012. /**
  15013. * Gets or sets the presentation attributes used to configure VR rendering
  15014. */
  15015. vrPresentationAttributes?: IVRPresentationAttributes;
  15016. /**
  15017. * Call this function to switch to webVR mode
  15018. * Will do nothing if webVR is not supported or if there is no webVR device
  15019. * @param options the webvr options provided to the camera. mainly used for multiview
  15020. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15021. */
  15022. enableVR(options: WebVROptions): void;
  15023. /** @hidden */
  15024. _onVRFullScreenTriggered(): void;
  15025. }
  15026. }
  15027. declare module BABYLON {
  15028. /**
  15029. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15030. * IMPORTANT!! The data is right-hand data.
  15031. * @export
  15032. * @interface DevicePose
  15033. */
  15034. export interface DevicePose {
  15035. /**
  15036. * The position of the device, values in array are [x,y,z].
  15037. */
  15038. readonly position: Nullable<Float32Array>;
  15039. /**
  15040. * The linearVelocity of the device, values in array are [x,y,z].
  15041. */
  15042. readonly linearVelocity: Nullable<Float32Array>;
  15043. /**
  15044. * The linearAcceleration of the device, values in array are [x,y,z].
  15045. */
  15046. readonly linearAcceleration: Nullable<Float32Array>;
  15047. /**
  15048. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15049. */
  15050. readonly orientation: Nullable<Float32Array>;
  15051. /**
  15052. * The angularVelocity of the device, values in array are [x,y,z].
  15053. */
  15054. readonly angularVelocity: Nullable<Float32Array>;
  15055. /**
  15056. * The angularAcceleration of the device, values in array are [x,y,z].
  15057. */
  15058. readonly angularAcceleration: Nullable<Float32Array>;
  15059. }
  15060. /**
  15061. * Interface representing a pose controlled object in Babylon.
  15062. * A pose controlled object has both regular pose values as well as pose values
  15063. * from an external device such as a VR head mounted display
  15064. */
  15065. export interface PoseControlled {
  15066. /**
  15067. * The position of the object in babylon space.
  15068. */
  15069. position: Vector3;
  15070. /**
  15071. * The rotation quaternion of the object in babylon space.
  15072. */
  15073. rotationQuaternion: Quaternion;
  15074. /**
  15075. * The position of the device in babylon space.
  15076. */
  15077. devicePosition?: Vector3;
  15078. /**
  15079. * The rotation quaternion of the device in babylon space.
  15080. */
  15081. deviceRotationQuaternion: Quaternion;
  15082. /**
  15083. * The raw pose coming from the device.
  15084. */
  15085. rawPose: Nullable<DevicePose>;
  15086. /**
  15087. * The scale of the device to be used when translating from device space to babylon space.
  15088. */
  15089. deviceScaleFactor: number;
  15090. /**
  15091. * Updates the poseControlled values based on the input device pose.
  15092. * @param poseData the pose data to update the object with
  15093. */
  15094. updateFromDevice(poseData: DevicePose): void;
  15095. }
  15096. /**
  15097. * Set of options to customize the webVRCamera
  15098. */
  15099. export interface WebVROptions {
  15100. /**
  15101. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15102. */
  15103. trackPosition?: boolean;
  15104. /**
  15105. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15106. */
  15107. positionScale?: number;
  15108. /**
  15109. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15110. */
  15111. displayName?: string;
  15112. /**
  15113. * Should the native controller meshes be initialized. (default: true)
  15114. */
  15115. controllerMeshes?: boolean;
  15116. /**
  15117. * Creating a default HemiLight only on controllers. (default: true)
  15118. */
  15119. defaultLightingOnControllers?: boolean;
  15120. /**
  15121. * If you don't want to use the default VR button of the helper. (default: false)
  15122. */
  15123. useCustomVRButton?: boolean;
  15124. /**
  15125. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15126. */
  15127. customVRButton?: HTMLButtonElement;
  15128. /**
  15129. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15130. */
  15131. rayLength?: number;
  15132. /**
  15133. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15134. */
  15135. defaultHeight?: number;
  15136. /**
  15137. * If multiview should be used if availible (default: false)
  15138. */
  15139. useMultiview?: boolean;
  15140. }
  15141. /**
  15142. * This represents a WebVR camera.
  15143. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15144. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15145. */
  15146. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15147. private webVROptions;
  15148. /**
  15149. * @hidden
  15150. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15151. */
  15152. _vrDevice: any;
  15153. /**
  15154. * The rawPose of the vrDevice.
  15155. */
  15156. rawPose: Nullable<DevicePose>;
  15157. private _onVREnabled;
  15158. private _specsVersion;
  15159. private _attached;
  15160. private _frameData;
  15161. protected _descendants: Array<Node>;
  15162. private _deviceRoomPosition;
  15163. /** @hidden */
  15164. _deviceRoomRotationQuaternion: Quaternion;
  15165. private _standingMatrix;
  15166. /**
  15167. * Represents device position in babylon space.
  15168. */
  15169. devicePosition: Vector3;
  15170. /**
  15171. * Represents device rotation in babylon space.
  15172. */
  15173. deviceRotationQuaternion: Quaternion;
  15174. /**
  15175. * The scale of the device to be used when translating from device space to babylon space.
  15176. */
  15177. deviceScaleFactor: number;
  15178. private _deviceToWorld;
  15179. private _worldToDevice;
  15180. /**
  15181. * References to the webVR controllers for the vrDevice.
  15182. */
  15183. controllers: Array<WebVRController>;
  15184. /**
  15185. * Emits an event when a controller is attached.
  15186. */
  15187. onControllersAttachedObservable: Observable<WebVRController[]>;
  15188. /**
  15189. * Emits an event when a controller's mesh has been loaded;
  15190. */
  15191. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15192. /**
  15193. * Emits an event when the HMD's pose has been updated.
  15194. */
  15195. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15196. private _poseSet;
  15197. /**
  15198. * If the rig cameras be used as parent instead of this camera.
  15199. */
  15200. rigParenting: boolean;
  15201. private _lightOnControllers;
  15202. private _defaultHeight?;
  15203. /**
  15204. * Instantiates a WebVRFreeCamera.
  15205. * @param name The name of the WebVRFreeCamera
  15206. * @param position The starting anchor position for the camera
  15207. * @param scene The scene the camera belongs to
  15208. * @param webVROptions a set of customizable options for the webVRCamera
  15209. */
  15210. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15211. /**
  15212. * Gets the device distance from the ground in meters.
  15213. * @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.
  15214. */
  15215. deviceDistanceToRoomGround(): number;
  15216. /**
  15217. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15218. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15219. */
  15220. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15221. /**
  15222. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15223. * @returns A promise with a boolean set to if the standing matrix is supported.
  15224. */
  15225. useStandingMatrixAsync(): Promise<boolean>;
  15226. /**
  15227. * Disposes the camera
  15228. */
  15229. dispose(): void;
  15230. /**
  15231. * Gets a vrController by name.
  15232. * @param name The name of the controller to retreive
  15233. * @returns the controller matching the name specified or null if not found
  15234. */
  15235. getControllerByName(name: string): Nullable<WebVRController>;
  15236. private _leftController;
  15237. /**
  15238. * The controller corresponding to the users left hand.
  15239. */
  15240. readonly leftController: Nullable<WebVRController>;
  15241. private _rightController;
  15242. /**
  15243. * The controller corresponding to the users right hand.
  15244. */
  15245. readonly rightController: Nullable<WebVRController>;
  15246. /**
  15247. * Casts a ray forward from the vrCamera's gaze.
  15248. * @param length Length of the ray (default: 100)
  15249. * @returns the ray corresponding to the gaze
  15250. */
  15251. getForwardRay(length?: number): Ray;
  15252. /**
  15253. * @hidden
  15254. * Updates the camera based on device's frame data
  15255. */
  15256. _checkInputs(): void;
  15257. /**
  15258. * Updates the poseControlled values based on the input device pose.
  15259. * @param poseData Pose coming from the device
  15260. */
  15261. updateFromDevice(poseData: DevicePose): void;
  15262. private _htmlElementAttached;
  15263. private _detachIfAttached;
  15264. /**
  15265. * WebVR's attach control will start broadcasting frames to the device.
  15266. * Note that in certain browsers (chrome for example) this function must be called
  15267. * within a user-interaction callback. Example:
  15268. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15269. *
  15270. * @param element html element to attach the vrDevice to
  15271. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15272. */
  15273. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15274. /**
  15275. * Detaches the camera from the html element and disables VR
  15276. *
  15277. * @param element html element to detach from
  15278. */
  15279. detachControl(element: HTMLElement): void;
  15280. /**
  15281. * @returns the name of this class
  15282. */
  15283. getClassName(): string;
  15284. /**
  15285. * Calls resetPose on the vrDisplay
  15286. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15287. */
  15288. resetToCurrentRotation(): void;
  15289. /**
  15290. * @hidden
  15291. * Updates the rig cameras (left and right eye)
  15292. */
  15293. _updateRigCameras(): void;
  15294. private _workingVector;
  15295. private _oneVector;
  15296. private _workingMatrix;
  15297. private updateCacheCalled;
  15298. private _correctPositionIfNotTrackPosition;
  15299. /**
  15300. * @hidden
  15301. * Updates the cached values of the camera
  15302. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15303. */
  15304. _updateCache(ignoreParentClass?: boolean): void;
  15305. /**
  15306. * @hidden
  15307. * Get current device position in babylon world
  15308. */
  15309. _computeDevicePosition(): void;
  15310. /**
  15311. * Updates the current device position and rotation in the babylon world
  15312. */
  15313. update(): void;
  15314. /**
  15315. * @hidden
  15316. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15317. * @returns an identity matrix
  15318. */
  15319. _getViewMatrix(): Matrix;
  15320. private _tmpMatrix;
  15321. /**
  15322. * This function is called by the two RIG cameras.
  15323. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15324. * @hidden
  15325. */
  15326. _getWebVRViewMatrix(): Matrix;
  15327. /** @hidden */
  15328. _getWebVRProjectionMatrix(): Matrix;
  15329. private _onGamepadConnectedObserver;
  15330. private _onGamepadDisconnectedObserver;
  15331. private _updateCacheWhenTrackingDisabledObserver;
  15332. /**
  15333. * Initializes the controllers and their meshes
  15334. */
  15335. initControllers(): void;
  15336. }
  15337. }
  15338. declare module BABYLON {
  15339. /**
  15340. * Size options for a post process
  15341. */
  15342. export type PostProcessOptions = {
  15343. width: number;
  15344. height: number;
  15345. };
  15346. /**
  15347. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15348. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15349. */
  15350. export class PostProcess {
  15351. /** Name of the PostProcess. */
  15352. name: string;
  15353. /**
  15354. * Gets or sets the unique id of the post process
  15355. */
  15356. uniqueId: number;
  15357. /**
  15358. * Width of the texture to apply the post process on
  15359. */
  15360. width: number;
  15361. /**
  15362. * Height of the texture to apply the post process on
  15363. */
  15364. height: number;
  15365. /**
  15366. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15367. * @hidden
  15368. */
  15369. _outputTexture: Nullable<InternalTexture>;
  15370. /**
  15371. * Sampling mode used by the shader
  15372. * See https://doc.babylonjs.com/classes/3.1/texture
  15373. */
  15374. renderTargetSamplingMode: number;
  15375. /**
  15376. * Clear color to use when screen clearing
  15377. */
  15378. clearColor: Color4;
  15379. /**
  15380. * If the buffer needs to be cleared before applying the post process. (default: true)
  15381. * Should be set to false if shader will overwrite all previous pixels.
  15382. */
  15383. autoClear: boolean;
  15384. /**
  15385. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15386. */
  15387. alphaMode: number;
  15388. /**
  15389. * Sets the setAlphaBlendConstants of the babylon engine
  15390. */
  15391. alphaConstants: Color4;
  15392. /**
  15393. * Animations to be used for the post processing
  15394. */
  15395. animations: Animation[];
  15396. /**
  15397. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15398. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15399. */
  15400. enablePixelPerfectMode: boolean;
  15401. /**
  15402. * Force the postprocess to be applied without taking in account viewport
  15403. */
  15404. forceFullscreenViewport: boolean;
  15405. /**
  15406. * List of inspectable custom properties (used by the Inspector)
  15407. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15408. */
  15409. inspectableCustomProperties: IInspectable[];
  15410. /**
  15411. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15412. *
  15413. * | Value | Type | Description |
  15414. * | ----- | ----------------------------------- | ----------- |
  15415. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15416. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15417. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15418. *
  15419. */
  15420. scaleMode: number;
  15421. /**
  15422. * Force textures to be a power of two (default: false)
  15423. */
  15424. alwaysForcePOT: boolean;
  15425. private _samples;
  15426. /**
  15427. * Number of sample textures (default: 1)
  15428. */
  15429. samples: number;
  15430. /**
  15431. * Modify the scale of the post process to be the same as the viewport (default: false)
  15432. */
  15433. adaptScaleToCurrentViewport: boolean;
  15434. private _camera;
  15435. private _scene;
  15436. private _engine;
  15437. private _options;
  15438. private _reusable;
  15439. private _textureType;
  15440. /**
  15441. * Smart array of input and output textures for the post process.
  15442. * @hidden
  15443. */
  15444. _textures: SmartArray<InternalTexture>;
  15445. /**
  15446. * The index in _textures that corresponds to the output texture.
  15447. * @hidden
  15448. */
  15449. _currentRenderTextureInd: number;
  15450. private _effect;
  15451. private _samplers;
  15452. private _fragmentUrl;
  15453. private _vertexUrl;
  15454. private _parameters;
  15455. private _scaleRatio;
  15456. protected _indexParameters: any;
  15457. private _shareOutputWithPostProcess;
  15458. private _texelSize;
  15459. private _forcedOutputTexture;
  15460. /**
  15461. * Returns the fragment url or shader name used in the post process.
  15462. * @returns the fragment url or name in the shader store.
  15463. */
  15464. getEffectName(): string;
  15465. /**
  15466. * An event triggered when the postprocess is activated.
  15467. */
  15468. onActivateObservable: Observable<Camera>;
  15469. private _onActivateObserver;
  15470. /**
  15471. * A function that is added to the onActivateObservable
  15472. */
  15473. onActivate: Nullable<(camera: Camera) => void>;
  15474. /**
  15475. * An event triggered when the postprocess changes its size.
  15476. */
  15477. onSizeChangedObservable: Observable<PostProcess>;
  15478. private _onSizeChangedObserver;
  15479. /**
  15480. * A function that is added to the onSizeChangedObservable
  15481. */
  15482. onSizeChanged: (postProcess: PostProcess) => void;
  15483. /**
  15484. * An event triggered when the postprocess applies its effect.
  15485. */
  15486. onApplyObservable: Observable<Effect>;
  15487. private _onApplyObserver;
  15488. /**
  15489. * A function that is added to the onApplyObservable
  15490. */
  15491. onApply: (effect: Effect) => void;
  15492. /**
  15493. * An event triggered before rendering the postprocess
  15494. */
  15495. onBeforeRenderObservable: Observable<Effect>;
  15496. private _onBeforeRenderObserver;
  15497. /**
  15498. * A function that is added to the onBeforeRenderObservable
  15499. */
  15500. onBeforeRender: (effect: Effect) => void;
  15501. /**
  15502. * An event triggered after rendering the postprocess
  15503. */
  15504. onAfterRenderObservable: Observable<Effect>;
  15505. private _onAfterRenderObserver;
  15506. /**
  15507. * A function that is added to the onAfterRenderObservable
  15508. */
  15509. onAfterRender: (efect: Effect) => void;
  15510. /**
  15511. * 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
  15512. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15513. */
  15514. inputTexture: InternalTexture;
  15515. /**
  15516. * Gets the camera which post process is applied to.
  15517. * @returns The camera the post process is applied to.
  15518. */
  15519. getCamera(): Camera;
  15520. /**
  15521. * Gets the texel size of the postprocess.
  15522. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15523. */
  15524. readonly texelSize: Vector2;
  15525. /**
  15526. * Creates a new instance PostProcess
  15527. * @param name The name of the PostProcess.
  15528. * @param fragmentUrl The url of the fragment shader to be used.
  15529. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15530. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15531. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15532. * @param camera The camera to apply the render pass to.
  15533. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15534. * @param engine The engine which the post process will be applied. (default: current engine)
  15535. * @param reusable If the post process can be reused on the same frame. (default: false)
  15536. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15537. * @param textureType Type of textures used when performing the post process. (default: 0)
  15538. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15539. * @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
  15540. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15541. */
  15542. constructor(
  15543. /** Name of the PostProcess. */
  15544. 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);
  15545. /**
  15546. * Gets a string idenfifying the name of the class
  15547. * @returns "PostProcess" string
  15548. */
  15549. getClassName(): string;
  15550. /**
  15551. * Gets the engine which this post process belongs to.
  15552. * @returns The engine the post process was enabled with.
  15553. */
  15554. getEngine(): Engine;
  15555. /**
  15556. * The effect that is created when initializing the post process.
  15557. * @returns The created effect corresponding the the postprocess.
  15558. */
  15559. getEffect(): Effect;
  15560. /**
  15561. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15562. * @param postProcess The post process to share the output with.
  15563. * @returns This post process.
  15564. */
  15565. shareOutputWith(postProcess: PostProcess): PostProcess;
  15566. /**
  15567. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15568. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15569. */
  15570. useOwnOutput(): void;
  15571. /**
  15572. * Updates the effect with the current post process compile time values and recompiles the shader.
  15573. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15574. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15575. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15576. * @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
  15577. * @param onCompiled Called when the shader has been compiled.
  15578. * @param onError Called if there is an error when compiling a shader.
  15579. */
  15580. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15581. /**
  15582. * The post process is reusable if it can be used multiple times within one frame.
  15583. * @returns If the post process is reusable
  15584. */
  15585. isReusable(): boolean;
  15586. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15587. markTextureDirty(): void;
  15588. /**
  15589. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15590. * 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.
  15591. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15592. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15593. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15594. * @returns The target texture that was bound to be written to.
  15595. */
  15596. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15597. /**
  15598. * If the post process is supported.
  15599. */
  15600. readonly isSupported: boolean;
  15601. /**
  15602. * The aspect ratio of the output texture.
  15603. */
  15604. readonly aspectRatio: number;
  15605. /**
  15606. * Get a value indicating if the post-process is ready to be used
  15607. * @returns true if the post-process is ready (shader is compiled)
  15608. */
  15609. isReady(): boolean;
  15610. /**
  15611. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15612. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15613. */
  15614. apply(): Nullable<Effect>;
  15615. private _disposeTextures;
  15616. /**
  15617. * Disposes the post process.
  15618. * @param camera The camera to dispose the post process on.
  15619. */
  15620. dispose(camera?: Camera): void;
  15621. }
  15622. }
  15623. declare module BABYLON {
  15624. /** @hidden */
  15625. export var kernelBlurVaryingDeclaration: {
  15626. name: string;
  15627. shader: string;
  15628. };
  15629. }
  15630. declare module BABYLON {
  15631. /** @hidden */
  15632. export var kernelBlurFragment: {
  15633. name: string;
  15634. shader: string;
  15635. };
  15636. }
  15637. declare module BABYLON {
  15638. /** @hidden */
  15639. export var kernelBlurFragment2: {
  15640. name: string;
  15641. shader: string;
  15642. };
  15643. }
  15644. declare module BABYLON {
  15645. /** @hidden */
  15646. export var kernelBlurPixelShader: {
  15647. name: string;
  15648. shader: string;
  15649. };
  15650. }
  15651. declare module BABYLON {
  15652. /** @hidden */
  15653. export var kernelBlurVertex: {
  15654. name: string;
  15655. shader: string;
  15656. };
  15657. }
  15658. declare module BABYLON {
  15659. /** @hidden */
  15660. export var kernelBlurVertexShader: {
  15661. name: string;
  15662. shader: string;
  15663. };
  15664. }
  15665. declare module BABYLON {
  15666. /**
  15667. * The Blur Post Process which blurs an image based on a kernel and direction.
  15668. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15669. */
  15670. export class BlurPostProcess extends PostProcess {
  15671. /** The direction in which to blur the image. */
  15672. direction: Vector2;
  15673. private blockCompilation;
  15674. protected _kernel: number;
  15675. protected _idealKernel: number;
  15676. protected _packedFloat: boolean;
  15677. private _staticDefines;
  15678. /**
  15679. * Sets the length in pixels of the blur sample region
  15680. */
  15681. /**
  15682. * Gets the length in pixels of the blur sample region
  15683. */
  15684. kernel: number;
  15685. /**
  15686. * Sets wether or not the blur needs to unpack/repack floats
  15687. */
  15688. /**
  15689. * Gets wether or not the blur is unpacking/repacking floats
  15690. */
  15691. packedFloat: boolean;
  15692. /**
  15693. * Creates a new instance BlurPostProcess
  15694. * @param name The name of the effect.
  15695. * @param direction The direction in which to blur the image.
  15696. * @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.
  15697. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15698. * @param camera The camera to apply the render pass to.
  15699. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15700. * @param engine The engine which the post process will be applied. (default: current engine)
  15701. * @param reusable If the post process can be reused on the same frame. (default: false)
  15702. * @param textureType Type of textures used when performing the post process. (default: 0)
  15703. * @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)
  15704. */
  15705. constructor(name: string,
  15706. /** The direction in which to blur the image. */
  15707. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15708. /**
  15709. * Updates the effect with the current post process compile time values and recompiles the shader.
  15710. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15711. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15712. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15713. * @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
  15714. * @param onCompiled Called when the shader has been compiled.
  15715. * @param onError Called if there is an error when compiling a shader.
  15716. */
  15717. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15718. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15719. /**
  15720. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15721. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15722. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15723. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15724. * The gaps between physical kernels are compensated for in the weighting of the samples
  15725. * @param idealKernel Ideal blur kernel.
  15726. * @return Nearest best kernel.
  15727. */
  15728. protected _nearestBestKernel(idealKernel: number): number;
  15729. /**
  15730. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15731. * @param x The point on the Gaussian distribution to sample.
  15732. * @return the value of the Gaussian function at x.
  15733. */
  15734. protected _gaussianWeight(x: number): number;
  15735. /**
  15736. * Generates a string that can be used as a floating point number in GLSL.
  15737. * @param x Value to print.
  15738. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15739. * @return GLSL float string.
  15740. */
  15741. protected _glslFloat(x: number, decimalFigures?: number): string;
  15742. }
  15743. }
  15744. declare module BABYLON {
  15745. /**
  15746. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15747. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15748. * You can then easily use it as a reflectionTexture on a flat surface.
  15749. * In case the surface is not a plane, please consider relying on reflection probes.
  15750. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15751. */
  15752. export class MirrorTexture extends RenderTargetTexture {
  15753. private scene;
  15754. /**
  15755. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15756. * 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.
  15757. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15758. */
  15759. mirrorPlane: Plane;
  15760. /**
  15761. * Define the blur ratio used to blur the reflection if needed.
  15762. */
  15763. blurRatio: number;
  15764. /**
  15765. * Define the adaptive blur kernel used to blur the reflection if needed.
  15766. * This will autocompute the closest best match for the `blurKernel`
  15767. */
  15768. adaptiveBlurKernel: number;
  15769. /**
  15770. * Define the blur kernel used to blur the reflection if needed.
  15771. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15772. */
  15773. blurKernel: number;
  15774. /**
  15775. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15776. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15777. */
  15778. blurKernelX: number;
  15779. /**
  15780. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15781. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15782. */
  15783. blurKernelY: number;
  15784. private _autoComputeBlurKernel;
  15785. protected _onRatioRescale(): void;
  15786. private _updateGammaSpace;
  15787. private _imageProcessingConfigChangeObserver;
  15788. private _transformMatrix;
  15789. private _mirrorMatrix;
  15790. private _savedViewMatrix;
  15791. private _blurX;
  15792. private _blurY;
  15793. private _adaptiveBlurKernel;
  15794. private _blurKernelX;
  15795. private _blurKernelY;
  15796. private _blurRatio;
  15797. /**
  15798. * Instantiates a Mirror Texture.
  15799. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15800. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15801. * You can then easily use it as a reflectionTexture on a flat surface.
  15802. * In case the surface is not a plane, please consider relying on reflection probes.
  15803. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15804. * @param name
  15805. * @param size
  15806. * @param scene
  15807. * @param generateMipMaps
  15808. * @param type
  15809. * @param samplingMode
  15810. * @param generateDepthBuffer
  15811. */
  15812. constructor(name: string, size: number | {
  15813. width: number;
  15814. height: number;
  15815. } | {
  15816. ratio: number;
  15817. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15818. private _preparePostProcesses;
  15819. /**
  15820. * Clone the mirror texture.
  15821. * @returns the cloned texture
  15822. */
  15823. clone(): MirrorTexture;
  15824. /**
  15825. * Serialize the texture to a JSON representation you could use in Parse later on
  15826. * @returns the serialized JSON representation
  15827. */
  15828. serialize(): any;
  15829. /**
  15830. * Dispose the texture and release its associated resources.
  15831. */
  15832. dispose(): void;
  15833. }
  15834. }
  15835. declare module BABYLON {
  15836. /**
  15837. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15838. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15839. */
  15840. export class Texture extends BaseTexture {
  15841. /**
  15842. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15843. */
  15844. static SerializeBuffers: boolean;
  15845. /** @hidden */
  15846. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15847. /** @hidden */
  15848. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15849. /** @hidden */
  15850. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15851. /** nearest is mag = nearest and min = nearest and mip = linear */
  15852. static readonly NEAREST_SAMPLINGMODE: number;
  15853. /** nearest is mag = nearest and min = nearest and mip = linear */
  15854. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15855. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15856. static readonly BILINEAR_SAMPLINGMODE: number;
  15857. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15858. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15859. /** Trilinear is mag = linear and min = linear and mip = linear */
  15860. static readonly TRILINEAR_SAMPLINGMODE: number;
  15861. /** Trilinear is mag = linear and min = linear and mip = linear */
  15862. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15863. /** mag = nearest and min = nearest and mip = nearest */
  15864. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15865. /** mag = nearest and min = linear and mip = nearest */
  15866. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15867. /** mag = nearest and min = linear and mip = linear */
  15868. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15869. /** mag = nearest and min = linear and mip = none */
  15870. static readonly NEAREST_LINEAR: number;
  15871. /** mag = nearest and min = nearest and mip = none */
  15872. static readonly NEAREST_NEAREST: number;
  15873. /** mag = linear and min = nearest and mip = nearest */
  15874. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15875. /** mag = linear and min = nearest and mip = linear */
  15876. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15877. /** mag = linear and min = linear and mip = none */
  15878. static readonly LINEAR_LINEAR: number;
  15879. /** mag = linear and min = nearest and mip = none */
  15880. static readonly LINEAR_NEAREST: number;
  15881. /** Explicit coordinates mode */
  15882. static readonly EXPLICIT_MODE: number;
  15883. /** Spherical coordinates mode */
  15884. static readonly SPHERICAL_MODE: number;
  15885. /** Planar coordinates mode */
  15886. static readonly PLANAR_MODE: number;
  15887. /** Cubic coordinates mode */
  15888. static readonly CUBIC_MODE: number;
  15889. /** Projection coordinates mode */
  15890. static readonly PROJECTION_MODE: number;
  15891. /** Inverse Cubic coordinates mode */
  15892. static readonly SKYBOX_MODE: number;
  15893. /** Inverse Cubic coordinates mode */
  15894. static readonly INVCUBIC_MODE: number;
  15895. /** Equirectangular coordinates mode */
  15896. static readonly EQUIRECTANGULAR_MODE: number;
  15897. /** Equirectangular Fixed coordinates mode */
  15898. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15899. /** Equirectangular Fixed Mirrored coordinates mode */
  15900. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15901. /** Texture is not repeating outside of 0..1 UVs */
  15902. static readonly CLAMP_ADDRESSMODE: number;
  15903. /** Texture is repeating outside of 0..1 UVs */
  15904. static readonly WRAP_ADDRESSMODE: number;
  15905. /** Texture is repeating and mirrored */
  15906. static readonly MIRROR_ADDRESSMODE: number;
  15907. /**
  15908. * 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
  15909. */
  15910. static UseSerializedUrlIfAny: boolean;
  15911. /**
  15912. * Define the url of the texture.
  15913. */
  15914. url: Nullable<string>;
  15915. /**
  15916. * Define an offset on the texture to offset the u coordinates of the UVs
  15917. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15918. */
  15919. uOffset: number;
  15920. /**
  15921. * Define an offset on the texture to offset the v coordinates of the UVs
  15922. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15923. */
  15924. vOffset: number;
  15925. /**
  15926. * Define an offset on the texture to scale the u coordinates of the UVs
  15927. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15928. */
  15929. uScale: number;
  15930. /**
  15931. * Define an offset on the texture to scale the v coordinates of the UVs
  15932. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15933. */
  15934. vScale: number;
  15935. /**
  15936. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15937. * @see http://doc.babylonjs.com/how_to/more_materials
  15938. */
  15939. uAng: number;
  15940. /**
  15941. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15942. * @see http://doc.babylonjs.com/how_to/more_materials
  15943. */
  15944. vAng: number;
  15945. /**
  15946. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15947. * @see http://doc.babylonjs.com/how_to/more_materials
  15948. */
  15949. wAng: number;
  15950. /**
  15951. * Defines the center of rotation (U)
  15952. */
  15953. uRotationCenter: number;
  15954. /**
  15955. * Defines the center of rotation (V)
  15956. */
  15957. vRotationCenter: number;
  15958. /**
  15959. * Defines the center of rotation (W)
  15960. */
  15961. wRotationCenter: number;
  15962. /**
  15963. * Are mip maps generated for this texture or not.
  15964. */
  15965. readonly noMipmap: boolean;
  15966. /**
  15967. * List of inspectable custom properties (used by the Inspector)
  15968. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15969. */
  15970. inspectableCustomProperties: Nullable<IInspectable[]>;
  15971. private _noMipmap;
  15972. /** @hidden */
  15973. _invertY: boolean;
  15974. private _rowGenerationMatrix;
  15975. private _cachedTextureMatrix;
  15976. private _projectionModeMatrix;
  15977. private _t0;
  15978. private _t1;
  15979. private _t2;
  15980. private _cachedUOffset;
  15981. private _cachedVOffset;
  15982. private _cachedUScale;
  15983. private _cachedVScale;
  15984. private _cachedUAng;
  15985. private _cachedVAng;
  15986. private _cachedWAng;
  15987. private _cachedProjectionMatrixId;
  15988. private _cachedCoordinatesMode;
  15989. /** @hidden */
  15990. protected _initialSamplingMode: number;
  15991. /** @hidden */
  15992. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  15993. private _deleteBuffer;
  15994. protected _format: Nullable<number>;
  15995. private _delayedOnLoad;
  15996. private _delayedOnError;
  15997. private _mimeType?;
  15998. /**
  15999. * Observable triggered once the texture has been loaded.
  16000. */
  16001. onLoadObservable: Observable<Texture>;
  16002. protected _isBlocking: boolean;
  16003. /**
  16004. * Is the texture preventing material to render while loading.
  16005. * If false, a default texture will be used instead of the loading one during the preparation step.
  16006. */
  16007. isBlocking: boolean;
  16008. /**
  16009. * Get the current sampling mode associated with the texture.
  16010. */
  16011. readonly samplingMode: number;
  16012. /**
  16013. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16014. */
  16015. readonly invertY: boolean;
  16016. /**
  16017. * Instantiates a new texture.
  16018. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16019. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16020. * @param url defines the url of the picture to load as a texture
  16021. * @param scene defines the scene or engine the texture will belong to
  16022. * @param noMipmap defines if the texture will require mip maps or not
  16023. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16024. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16025. * @param onLoad defines a callback triggered when the texture has been loaded
  16026. * @param onError defines a callback triggered when an error occurred during the loading session
  16027. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16028. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16029. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16030. * @param mimeType defines an optional mime type information
  16031. */
  16032. 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);
  16033. /**
  16034. * Update the url (and optional buffer) of this texture if url was null during construction.
  16035. * @param url the url of the texture
  16036. * @param buffer the buffer of the texture (defaults to null)
  16037. * @param onLoad callback called when the texture is loaded (defaults to null)
  16038. */
  16039. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16040. /**
  16041. * Finish the loading sequence of a texture flagged as delayed load.
  16042. * @hidden
  16043. */
  16044. delayLoad(): void;
  16045. private _prepareRowForTextureGeneration;
  16046. /**
  16047. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16048. * @returns the transform matrix of the texture.
  16049. */
  16050. getTextureMatrix(uBase?: number): Matrix;
  16051. /**
  16052. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16053. * @returns The reflection texture transform
  16054. */
  16055. getReflectionTextureMatrix(): Matrix;
  16056. /**
  16057. * Clones the texture.
  16058. * @returns the cloned texture
  16059. */
  16060. clone(): Texture;
  16061. /**
  16062. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16063. * @returns The JSON representation of the texture
  16064. */
  16065. serialize(): any;
  16066. /**
  16067. * Get the current class name of the texture useful for serialization or dynamic coding.
  16068. * @returns "Texture"
  16069. */
  16070. getClassName(): string;
  16071. /**
  16072. * Dispose the texture and release its associated resources.
  16073. */
  16074. dispose(): void;
  16075. /**
  16076. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16077. * @param parsedTexture Define the JSON representation of the texture
  16078. * @param scene Define the scene the parsed texture should be instantiated in
  16079. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16080. * @returns The parsed texture if successful
  16081. */
  16082. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16083. /**
  16084. * Creates a texture from its base 64 representation.
  16085. * @param data Define the base64 payload without the data: prefix
  16086. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16087. * @param scene Define the scene the texture should belong to
  16088. * @param noMipmap Forces the texture to not create mip map information if true
  16089. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16090. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16091. * @param onLoad define a callback triggered when the texture has been loaded
  16092. * @param onError define a callback triggered when an error occurred during the loading session
  16093. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16094. * @returns the created texture
  16095. */
  16096. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16097. /**
  16098. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16099. * @param data Define the base64 payload without the data: prefix
  16100. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16101. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16102. * @param scene Define the scene the texture should belong to
  16103. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16104. * @param noMipmap Forces the texture to not create mip map information if true
  16105. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16106. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16107. * @param onLoad define a callback triggered when the texture has been loaded
  16108. * @param onError define a callback triggered when an error occurred during the loading session
  16109. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16110. * @returns the created texture
  16111. */
  16112. 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;
  16113. }
  16114. }
  16115. declare module BABYLON {
  16116. /**
  16117. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16118. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16119. */
  16120. export class PostProcessManager {
  16121. private _scene;
  16122. private _indexBuffer;
  16123. private _vertexBuffers;
  16124. /**
  16125. * Creates a new instance PostProcess
  16126. * @param scene The scene that the post process is associated with.
  16127. */
  16128. constructor(scene: Scene);
  16129. private _prepareBuffers;
  16130. private _buildIndexBuffer;
  16131. /**
  16132. * Rebuilds the vertex buffers of the manager.
  16133. * @hidden
  16134. */
  16135. _rebuild(): void;
  16136. /**
  16137. * Prepares a frame to be run through a post process.
  16138. * @param sourceTexture The input texture to the post procesess. (default: null)
  16139. * @param postProcesses An array of post processes to be run. (default: null)
  16140. * @returns True if the post processes were able to be run.
  16141. * @hidden
  16142. */
  16143. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16144. /**
  16145. * Manually render a set of post processes to a texture.
  16146. * @param postProcesses An array of post processes to be run.
  16147. * @param targetTexture The target texture to render to.
  16148. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16149. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16150. * @param lodLevel defines which lod of the texture to render to
  16151. */
  16152. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16153. /**
  16154. * Finalize the result of the output of the postprocesses.
  16155. * @param doNotPresent If true the result will not be displayed to the screen.
  16156. * @param targetTexture The target texture to render to.
  16157. * @param faceIndex The index of the face to bind the target texture to.
  16158. * @param postProcesses The array of post processes to render.
  16159. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16160. * @hidden
  16161. */
  16162. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16163. /**
  16164. * Disposes of the post process manager.
  16165. */
  16166. dispose(): void;
  16167. }
  16168. }
  16169. declare module BABYLON {
  16170. /** Interface used by value gradients (color, factor, ...) */
  16171. export interface IValueGradient {
  16172. /**
  16173. * Gets or sets the gradient value (between 0 and 1)
  16174. */
  16175. gradient: number;
  16176. }
  16177. /** Class used to store color4 gradient */
  16178. export class ColorGradient implements IValueGradient {
  16179. /**
  16180. * Gets or sets the gradient value (between 0 and 1)
  16181. */
  16182. gradient: number;
  16183. /**
  16184. * Gets or sets first associated color
  16185. */
  16186. color1: Color4;
  16187. /**
  16188. * Gets or sets second associated color
  16189. */
  16190. color2?: Color4;
  16191. /**
  16192. * Will get a color picked randomly between color1 and color2.
  16193. * If color2 is undefined then color1 will be used
  16194. * @param result defines the target Color4 to store the result in
  16195. */
  16196. getColorToRef(result: Color4): void;
  16197. }
  16198. /** Class used to store color 3 gradient */
  16199. export class Color3Gradient implements IValueGradient {
  16200. /**
  16201. * Gets or sets the gradient value (between 0 and 1)
  16202. */
  16203. gradient: number;
  16204. /**
  16205. * Gets or sets the associated color
  16206. */
  16207. color: Color3;
  16208. }
  16209. /** Class used to store factor gradient */
  16210. export class FactorGradient implements IValueGradient {
  16211. /**
  16212. * Gets or sets the gradient value (between 0 and 1)
  16213. */
  16214. gradient: number;
  16215. /**
  16216. * Gets or sets first associated factor
  16217. */
  16218. factor1: number;
  16219. /**
  16220. * Gets or sets second associated factor
  16221. */
  16222. factor2?: number;
  16223. /**
  16224. * Will get a number picked randomly between factor1 and factor2.
  16225. * If factor2 is undefined then factor1 will be used
  16226. * @returns the picked number
  16227. */
  16228. getFactor(): number;
  16229. }
  16230. /**
  16231. * Helper used to simplify some generic gradient tasks
  16232. */
  16233. export class GradientHelper {
  16234. /**
  16235. * Gets the current gradient from an array of IValueGradient
  16236. * @param ratio defines the current ratio to get
  16237. * @param gradients defines the array of IValueGradient
  16238. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16239. */
  16240. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16241. }
  16242. }
  16243. declare module BABYLON {
  16244. interface ThinEngine {
  16245. /**
  16246. * Creates a dynamic texture
  16247. * @param width defines the width of the texture
  16248. * @param height defines the height of the texture
  16249. * @param generateMipMaps defines if the engine should generate the mip levels
  16250. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16251. * @returns the dynamic texture inside an InternalTexture
  16252. */
  16253. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16254. /**
  16255. * Update the content of a dynamic texture
  16256. * @param texture defines the texture to update
  16257. * @param canvas defines the canvas containing the source
  16258. * @param invertY defines if data must be stored with Y axis inverted
  16259. * @param premulAlpha defines if alpha is stored as premultiplied
  16260. * @param format defines the format of the data
  16261. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16262. */
  16263. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16264. }
  16265. }
  16266. declare module BABYLON {
  16267. /**
  16268. * Helper class used to generate a canvas to manipulate images
  16269. */
  16270. export class CanvasGenerator {
  16271. /**
  16272. * Create a new canvas (or offscreen canvas depending on the context)
  16273. * @param width defines the expected width
  16274. * @param height defines the expected height
  16275. * @return a new canvas or offscreen canvas
  16276. */
  16277. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16278. }
  16279. }
  16280. declare module BABYLON {
  16281. /**
  16282. * A class extending Texture allowing drawing on a texture
  16283. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16284. */
  16285. export class DynamicTexture extends Texture {
  16286. private _generateMipMaps;
  16287. private _canvas;
  16288. private _context;
  16289. private _engine;
  16290. /**
  16291. * Creates a DynamicTexture
  16292. * @param name defines the name of the texture
  16293. * @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
  16294. * @param scene defines the scene where you want the texture
  16295. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16296. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16297. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16298. */
  16299. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16300. /**
  16301. * Get the current class name of the texture useful for serialization or dynamic coding.
  16302. * @returns "DynamicTexture"
  16303. */
  16304. getClassName(): string;
  16305. /**
  16306. * Gets the current state of canRescale
  16307. */
  16308. readonly canRescale: boolean;
  16309. private _recreate;
  16310. /**
  16311. * Scales the texture
  16312. * @param ratio the scale factor to apply to both width and height
  16313. */
  16314. scale(ratio: number): void;
  16315. /**
  16316. * Resizes the texture
  16317. * @param width the new width
  16318. * @param height the new height
  16319. */
  16320. scaleTo(width: number, height: number): void;
  16321. /**
  16322. * Gets the context of the canvas used by the texture
  16323. * @returns the canvas context of the dynamic texture
  16324. */
  16325. getContext(): CanvasRenderingContext2D;
  16326. /**
  16327. * Clears the texture
  16328. */
  16329. clear(): void;
  16330. /**
  16331. * Updates the texture
  16332. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16333. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16334. */
  16335. update(invertY?: boolean, premulAlpha?: boolean): void;
  16336. /**
  16337. * Draws text onto the texture
  16338. * @param text defines the text to be drawn
  16339. * @param x defines the placement of the text from the left
  16340. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16341. * @param font defines the font to be used with font-style, font-size, font-name
  16342. * @param color defines the color used for the text
  16343. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16344. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16345. * @param update defines whether texture is immediately update (default is true)
  16346. */
  16347. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16348. /**
  16349. * Clones the texture
  16350. * @returns the clone of the texture.
  16351. */
  16352. clone(): DynamicTexture;
  16353. /**
  16354. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16355. * @returns a serialized dynamic texture object
  16356. */
  16357. serialize(): any;
  16358. /** @hidden */
  16359. _rebuild(): void;
  16360. }
  16361. }
  16362. declare module BABYLON {
  16363. interface AbstractScene {
  16364. /**
  16365. * The list of procedural textures added to the scene
  16366. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16367. */
  16368. proceduralTextures: Array<ProceduralTexture>;
  16369. }
  16370. /**
  16371. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16372. * in a given scene.
  16373. */
  16374. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16375. /**
  16376. * The component name helpfull to identify the component in the list of scene components.
  16377. */
  16378. readonly name: string;
  16379. /**
  16380. * The scene the component belongs to.
  16381. */
  16382. scene: Scene;
  16383. /**
  16384. * Creates a new instance of the component for the given scene
  16385. * @param scene Defines the scene to register the component in
  16386. */
  16387. constructor(scene: Scene);
  16388. /**
  16389. * Registers the component in a given scene
  16390. */
  16391. register(): void;
  16392. /**
  16393. * Rebuilds the elements related to this component in case of
  16394. * context lost for instance.
  16395. */
  16396. rebuild(): void;
  16397. /**
  16398. * Disposes the component and the associated ressources.
  16399. */
  16400. dispose(): void;
  16401. private _beforeClear;
  16402. }
  16403. }
  16404. declare module BABYLON {
  16405. interface ThinEngine {
  16406. /**
  16407. * Creates a new render target cube texture
  16408. * @param size defines the size of the texture
  16409. * @param options defines the options used to create the texture
  16410. * @returns a new render target cube texture stored in an InternalTexture
  16411. */
  16412. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16413. }
  16414. }
  16415. declare module BABYLON {
  16416. /** @hidden */
  16417. export var proceduralVertexShader: {
  16418. name: string;
  16419. shader: string;
  16420. };
  16421. }
  16422. declare module BABYLON {
  16423. /**
  16424. * 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.
  16425. * This is the base class of any Procedural texture and contains most of the shareable code.
  16426. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16427. */
  16428. export class ProceduralTexture extends Texture {
  16429. isCube: boolean;
  16430. /**
  16431. * Define if the texture is enabled or not (disabled texture will not render)
  16432. */
  16433. isEnabled: boolean;
  16434. /**
  16435. * Define if the texture must be cleared before rendering (default is true)
  16436. */
  16437. autoClear: boolean;
  16438. /**
  16439. * Callback called when the texture is generated
  16440. */
  16441. onGenerated: () => void;
  16442. /**
  16443. * Event raised when the texture is generated
  16444. */
  16445. onGeneratedObservable: Observable<ProceduralTexture>;
  16446. /** @hidden */
  16447. _generateMipMaps: boolean;
  16448. /** @hidden **/
  16449. _effect: Effect;
  16450. /** @hidden */
  16451. _textures: {
  16452. [key: string]: Texture;
  16453. };
  16454. private _size;
  16455. private _currentRefreshId;
  16456. private _refreshRate;
  16457. private _vertexBuffers;
  16458. private _indexBuffer;
  16459. private _uniforms;
  16460. private _samplers;
  16461. private _fragment;
  16462. private _floats;
  16463. private _ints;
  16464. private _floatsArrays;
  16465. private _colors3;
  16466. private _colors4;
  16467. private _vectors2;
  16468. private _vectors3;
  16469. private _matrices;
  16470. private _fallbackTexture;
  16471. private _fallbackTextureUsed;
  16472. private _engine;
  16473. private _cachedDefines;
  16474. private _contentUpdateId;
  16475. private _contentData;
  16476. /**
  16477. * Instantiates a new procedural texture.
  16478. * 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.
  16479. * This is the base class of any Procedural texture and contains most of the shareable code.
  16480. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16481. * @param name Define the name of the texture
  16482. * @param size Define the size of the texture to create
  16483. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16484. * @param scene Define the scene the texture belongs to
  16485. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16486. * @param generateMipMaps Define if the texture should creates mip maps or not
  16487. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16488. */
  16489. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16490. /**
  16491. * The effect that is created when initializing the post process.
  16492. * @returns The created effect corresponding the the postprocess.
  16493. */
  16494. getEffect(): Effect;
  16495. /**
  16496. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16497. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16498. */
  16499. getContent(): Nullable<ArrayBufferView>;
  16500. private _createIndexBuffer;
  16501. /** @hidden */
  16502. _rebuild(): void;
  16503. /**
  16504. * Resets the texture in order to recreate its associated resources.
  16505. * This can be called in case of context loss
  16506. */
  16507. reset(): void;
  16508. protected _getDefines(): string;
  16509. /**
  16510. * Is the texture ready to be used ? (rendered at least once)
  16511. * @returns true if ready, otherwise, false.
  16512. */
  16513. isReady(): boolean;
  16514. /**
  16515. * Resets the refresh counter of the texture and start bak from scratch.
  16516. * Could be useful to regenerate the texture if it is setup to render only once.
  16517. */
  16518. resetRefreshCounter(): void;
  16519. /**
  16520. * Set the fragment shader to use in order to render the texture.
  16521. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16522. */
  16523. setFragment(fragment: any): void;
  16524. /**
  16525. * Define the refresh rate of the texture or the rendering frequency.
  16526. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16527. */
  16528. refreshRate: number;
  16529. /** @hidden */
  16530. _shouldRender(): boolean;
  16531. /**
  16532. * Get the size the texture is rendering at.
  16533. * @returns the size (texture is always squared)
  16534. */
  16535. getRenderSize(): number;
  16536. /**
  16537. * Resize the texture to new value.
  16538. * @param size Define the new size the texture should have
  16539. * @param generateMipMaps Define whether the new texture should create mip maps
  16540. */
  16541. resize(size: number, generateMipMaps: boolean): void;
  16542. private _checkUniform;
  16543. /**
  16544. * Set a texture in the shader program used to render.
  16545. * @param name Define the name of the uniform samplers as defined in the shader
  16546. * @param texture Define the texture to bind to this sampler
  16547. * @return the texture itself allowing "fluent" like uniform updates
  16548. */
  16549. setTexture(name: string, texture: Texture): ProceduralTexture;
  16550. /**
  16551. * Set a float in the shader.
  16552. * @param name Define the name of the uniform as defined in the shader
  16553. * @param value Define the value to give to the uniform
  16554. * @return the texture itself allowing "fluent" like uniform updates
  16555. */
  16556. setFloat(name: string, value: number): ProceduralTexture;
  16557. /**
  16558. * Set a int in the shader.
  16559. * @param name Define the name of the uniform as defined in the shader
  16560. * @param value Define the value to give to the uniform
  16561. * @return the texture itself allowing "fluent" like uniform updates
  16562. */
  16563. setInt(name: string, value: number): ProceduralTexture;
  16564. /**
  16565. * Set an array of floats in the shader.
  16566. * @param name Define the name of the uniform as defined in the shader
  16567. * @param value Define the value to give to the uniform
  16568. * @return the texture itself allowing "fluent" like uniform updates
  16569. */
  16570. setFloats(name: string, value: number[]): ProceduralTexture;
  16571. /**
  16572. * Set a vec3 in the shader from a Color3.
  16573. * @param name Define the name of the uniform as defined in the shader
  16574. * @param value Define the value to give to the uniform
  16575. * @return the texture itself allowing "fluent" like uniform updates
  16576. */
  16577. setColor3(name: string, value: Color3): ProceduralTexture;
  16578. /**
  16579. * Set a vec4 in the shader from a Color4.
  16580. * @param name Define the name of the uniform as defined in the shader
  16581. * @param value Define the value to give to the uniform
  16582. * @return the texture itself allowing "fluent" like uniform updates
  16583. */
  16584. setColor4(name: string, value: Color4): ProceduralTexture;
  16585. /**
  16586. * Set a vec2 in the shader from a Vector2.
  16587. * @param name Define the name of the uniform as defined in the shader
  16588. * @param value Define the value to give to the uniform
  16589. * @return the texture itself allowing "fluent" like uniform updates
  16590. */
  16591. setVector2(name: string, value: Vector2): ProceduralTexture;
  16592. /**
  16593. * Set a vec3 in the shader from a Vector3.
  16594. * @param name Define the name of the uniform as defined in the shader
  16595. * @param value Define the value to give to the uniform
  16596. * @return the texture itself allowing "fluent" like uniform updates
  16597. */
  16598. setVector3(name: string, value: Vector3): ProceduralTexture;
  16599. /**
  16600. * Set a mat4 in the shader from a MAtrix.
  16601. * @param name Define the name of the uniform as defined in the shader
  16602. * @param value Define the value to give to the uniform
  16603. * @return the texture itself allowing "fluent" like uniform updates
  16604. */
  16605. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16606. /**
  16607. * Render the texture to its associated render target.
  16608. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16609. */
  16610. render(useCameraPostProcess?: boolean): void;
  16611. /**
  16612. * Clone the texture.
  16613. * @returns the cloned texture
  16614. */
  16615. clone(): ProceduralTexture;
  16616. /**
  16617. * Dispose the texture and release its asoociated resources.
  16618. */
  16619. dispose(): void;
  16620. }
  16621. }
  16622. declare module BABYLON {
  16623. /**
  16624. * This represents the base class for particle system in Babylon.
  16625. * 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.
  16626. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16627. * @example https://doc.babylonjs.com/babylon101/particles
  16628. */
  16629. export class BaseParticleSystem {
  16630. /**
  16631. * Source color is added to the destination color without alpha affecting the result
  16632. */
  16633. static BLENDMODE_ONEONE: number;
  16634. /**
  16635. * Blend current color and particle color using particle’s alpha
  16636. */
  16637. static BLENDMODE_STANDARD: number;
  16638. /**
  16639. * Add current color and particle color multiplied by particle’s alpha
  16640. */
  16641. static BLENDMODE_ADD: number;
  16642. /**
  16643. * Multiply current color with particle color
  16644. */
  16645. static BLENDMODE_MULTIPLY: number;
  16646. /**
  16647. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16648. */
  16649. static BLENDMODE_MULTIPLYADD: number;
  16650. /**
  16651. * List of animations used by the particle system.
  16652. */
  16653. animations: Animation[];
  16654. /**
  16655. * The id of the Particle system.
  16656. */
  16657. id: string;
  16658. /**
  16659. * The friendly name of the Particle system.
  16660. */
  16661. name: string;
  16662. /**
  16663. * The rendering group used by the Particle system to chose when to render.
  16664. */
  16665. renderingGroupId: number;
  16666. /**
  16667. * The emitter represents the Mesh or position we are attaching the particle system to.
  16668. */
  16669. emitter: Nullable<AbstractMesh | Vector3>;
  16670. /**
  16671. * The maximum number of particles to emit per frame
  16672. */
  16673. emitRate: number;
  16674. /**
  16675. * If you want to launch only a few particles at once, that can be done, as well.
  16676. */
  16677. manualEmitCount: number;
  16678. /**
  16679. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16680. */
  16681. updateSpeed: number;
  16682. /**
  16683. * The amount of time the particle system is running (depends of the overall update speed).
  16684. */
  16685. targetStopDuration: number;
  16686. /**
  16687. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16688. */
  16689. disposeOnStop: boolean;
  16690. /**
  16691. * Minimum power of emitting particles.
  16692. */
  16693. minEmitPower: number;
  16694. /**
  16695. * Maximum power of emitting particles.
  16696. */
  16697. maxEmitPower: number;
  16698. /**
  16699. * Minimum life time of emitting particles.
  16700. */
  16701. minLifeTime: number;
  16702. /**
  16703. * Maximum life time of emitting particles.
  16704. */
  16705. maxLifeTime: number;
  16706. /**
  16707. * Minimum Size of emitting particles.
  16708. */
  16709. minSize: number;
  16710. /**
  16711. * Maximum Size of emitting particles.
  16712. */
  16713. maxSize: number;
  16714. /**
  16715. * Minimum scale of emitting particles on X axis.
  16716. */
  16717. minScaleX: number;
  16718. /**
  16719. * Maximum scale of emitting particles on X axis.
  16720. */
  16721. maxScaleX: number;
  16722. /**
  16723. * Minimum scale of emitting particles on Y axis.
  16724. */
  16725. minScaleY: number;
  16726. /**
  16727. * Maximum scale of emitting particles on Y axis.
  16728. */
  16729. maxScaleY: number;
  16730. /**
  16731. * Gets or sets the minimal initial rotation in radians.
  16732. */
  16733. minInitialRotation: number;
  16734. /**
  16735. * Gets or sets the maximal initial rotation in radians.
  16736. */
  16737. maxInitialRotation: number;
  16738. /**
  16739. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16740. */
  16741. minAngularSpeed: number;
  16742. /**
  16743. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16744. */
  16745. maxAngularSpeed: number;
  16746. /**
  16747. * The texture used to render each particle. (this can be a spritesheet)
  16748. */
  16749. particleTexture: Nullable<Texture>;
  16750. /**
  16751. * The layer mask we are rendering the particles through.
  16752. */
  16753. layerMask: number;
  16754. /**
  16755. * This can help using your own shader to render the particle system.
  16756. * The according effect will be created
  16757. */
  16758. customShader: any;
  16759. /**
  16760. * By default particle system starts as soon as they are created. This prevents the
  16761. * automatic start to happen and let you decide when to start emitting particles.
  16762. */
  16763. preventAutoStart: boolean;
  16764. private _noiseTexture;
  16765. /**
  16766. * Gets or sets a texture used to add random noise to particle positions
  16767. */
  16768. noiseTexture: Nullable<ProceduralTexture>;
  16769. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16770. noiseStrength: Vector3;
  16771. /**
  16772. * Callback triggered when the particle animation is ending.
  16773. */
  16774. onAnimationEnd: Nullable<() => void>;
  16775. /**
  16776. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16777. */
  16778. blendMode: number;
  16779. /**
  16780. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16781. * to override the particles.
  16782. */
  16783. forceDepthWrite: boolean;
  16784. /** 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 */
  16785. preWarmCycles: number;
  16786. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16787. preWarmStepOffset: number;
  16788. /**
  16789. * 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)
  16790. */
  16791. spriteCellChangeSpeed: number;
  16792. /**
  16793. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16794. */
  16795. startSpriteCellID: number;
  16796. /**
  16797. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16798. */
  16799. endSpriteCellID: number;
  16800. /**
  16801. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16802. */
  16803. spriteCellWidth: number;
  16804. /**
  16805. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16806. */
  16807. spriteCellHeight: number;
  16808. /**
  16809. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16810. */
  16811. spriteRandomStartCell: boolean;
  16812. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16813. translationPivot: Vector2;
  16814. /** @hidden */
  16815. protected _isAnimationSheetEnabled: boolean;
  16816. /**
  16817. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16818. */
  16819. beginAnimationOnStart: boolean;
  16820. /**
  16821. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16822. */
  16823. beginAnimationFrom: number;
  16824. /**
  16825. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16826. */
  16827. beginAnimationTo: number;
  16828. /**
  16829. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16830. */
  16831. beginAnimationLoop: boolean;
  16832. /**
  16833. * Gets or sets a world offset applied to all particles
  16834. */
  16835. worldOffset: Vector3;
  16836. /**
  16837. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16838. */
  16839. isAnimationSheetEnabled: boolean;
  16840. /**
  16841. * Get hosting scene
  16842. * @returns the scene
  16843. */
  16844. getScene(): Scene;
  16845. /**
  16846. * You can use gravity if you want to give an orientation to your particles.
  16847. */
  16848. gravity: Vector3;
  16849. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16850. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16851. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16852. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16853. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16854. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16855. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16856. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16857. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16858. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16859. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16860. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16861. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16862. /**
  16863. * Defines the delay in milliseconds before starting the system (0 by default)
  16864. */
  16865. startDelay: number;
  16866. /**
  16867. * Gets the current list of drag gradients.
  16868. * You must use addDragGradient and removeDragGradient to udpate this list
  16869. * @returns the list of drag gradients
  16870. */
  16871. getDragGradients(): Nullable<Array<FactorGradient>>;
  16872. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16873. limitVelocityDamping: number;
  16874. /**
  16875. * Gets the current list of limit velocity gradients.
  16876. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16877. * @returns the list of limit velocity gradients
  16878. */
  16879. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16880. /**
  16881. * Gets the current list of color gradients.
  16882. * You must use addColorGradient and removeColorGradient to udpate this list
  16883. * @returns the list of color gradients
  16884. */
  16885. getColorGradients(): Nullable<Array<ColorGradient>>;
  16886. /**
  16887. * Gets the current list of size gradients.
  16888. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16889. * @returns the list of size gradients
  16890. */
  16891. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16892. /**
  16893. * Gets the current list of color remap gradients.
  16894. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16895. * @returns the list of color remap gradients
  16896. */
  16897. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16898. /**
  16899. * Gets the current list of alpha remap gradients.
  16900. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16901. * @returns the list of alpha remap gradients
  16902. */
  16903. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16904. /**
  16905. * Gets the current list of life time gradients.
  16906. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16907. * @returns the list of life time gradients
  16908. */
  16909. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16910. /**
  16911. * Gets the current list of angular speed gradients.
  16912. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16913. * @returns the list of angular speed gradients
  16914. */
  16915. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16916. /**
  16917. * Gets the current list of velocity gradients.
  16918. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16919. * @returns the list of velocity gradients
  16920. */
  16921. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16922. /**
  16923. * Gets the current list of start size gradients.
  16924. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16925. * @returns the list of start size gradients
  16926. */
  16927. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16928. /**
  16929. * Gets the current list of emit rate gradients.
  16930. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16931. * @returns the list of emit rate gradients
  16932. */
  16933. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16934. /**
  16935. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16936. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16937. */
  16938. direction1: Vector3;
  16939. /**
  16940. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16941. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16942. */
  16943. direction2: Vector3;
  16944. /**
  16945. * 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.
  16946. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16947. */
  16948. minEmitBox: Vector3;
  16949. /**
  16950. * 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.
  16951. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16952. */
  16953. maxEmitBox: Vector3;
  16954. /**
  16955. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16956. */
  16957. color1: Color4;
  16958. /**
  16959. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16960. */
  16961. color2: Color4;
  16962. /**
  16963. * Color the particle will have at the end of its lifetime
  16964. */
  16965. colorDead: Color4;
  16966. /**
  16967. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16968. */
  16969. textureMask: Color4;
  16970. /**
  16971. * The particle emitter type defines the emitter used by the particle system.
  16972. * It can be for example box, sphere, or cone...
  16973. */
  16974. particleEmitterType: IParticleEmitterType;
  16975. /** @hidden */
  16976. _isSubEmitter: boolean;
  16977. /**
  16978. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16979. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16980. */
  16981. billboardMode: number;
  16982. protected _isBillboardBased: boolean;
  16983. /**
  16984. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16985. */
  16986. isBillboardBased: boolean;
  16987. /**
  16988. * The scene the particle system belongs to.
  16989. */
  16990. protected _scene: Scene;
  16991. /**
  16992. * Local cache of defines for image processing.
  16993. */
  16994. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16995. /**
  16996. * Default configuration related to image processing available in the standard Material.
  16997. */
  16998. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16999. /**
  17000. * Gets the image processing configuration used either in this material.
  17001. */
  17002. /**
  17003. * Sets the Default image processing configuration used either in the this material.
  17004. *
  17005. * If sets to null, the scene one is in use.
  17006. */
  17007. imageProcessingConfiguration: ImageProcessingConfiguration;
  17008. /**
  17009. * Attaches a new image processing configuration to the Standard Material.
  17010. * @param configuration
  17011. */
  17012. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17013. /** @hidden */
  17014. protected _reset(): void;
  17015. /** @hidden */
  17016. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17017. /**
  17018. * Instantiates a particle system.
  17019. * 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.
  17020. * @param name The name of the particle system
  17021. */
  17022. constructor(name: string);
  17023. /**
  17024. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17025. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17026. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17027. * @returns the emitter
  17028. */
  17029. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17030. /**
  17031. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17032. * @param radius The radius of the hemisphere to emit from
  17033. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17034. * @returns the emitter
  17035. */
  17036. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17037. /**
  17038. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17039. * @param radius The radius of the sphere to emit from
  17040. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17041. * @returns the emitter
  17042. */
  17043. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17044. /**
  17045. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17046. * @param radius The radius of the sphere to emit from
  17047. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17048. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17049. * @returns the emitter
  17050. */
  17051. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17052. /**
  17053. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17054. * @param radius The radius of the emission cylinder
  17055. * @param height The height of the emission cylinder
  17056. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17057. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17058. * @returns the emitter
  17059. */
  17060. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17061. /**
  17062. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17063. * @param radius The radius of the cylinder to emit from
  17064. * @param height The height of the emission cylinder
  17065. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17066. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17067. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17068. * @returns the emitter
  17069. */
  17070. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17071. /**
  17072. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17073. * @param radius The radius of the cone to emit from
  17074. * @param angle The base angle of the cone
  17075. * @returns the emitter
  17076. */
  17077. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17078. /**
  17079. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17080. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17081. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17082. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17083. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17084. * @returns the emitter
  17085. */
  17086. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17087. }
  17088. }
  17089. declare module BABYLON {
  17090. /**
  17091. * Type of sub emitter
  17092. */
  17093. export enum SubEmitterType {
  17094. /**
  17095. * Attached to the particle over it's lifetime
  17096. */
  17097. ATTACHED = 0,
  17098. /**
  17099. * Created when the particle dies
  17100. */
  17101. END = 1
  17102. }
  17103. /**
  17104. * Sub emitter class used to emit particles from an existing particle
  17105. */
  17106. export class SubEmitter {
  17107. /**
  17108. * the particle system to be used by the sub emitter
  17109. */
  17110. particleSystem: ParticleSystem;
  17111. /**
  17112. * Type of the submitter (Default: END)
  17113. */
  17114. type: SubEmitterType;
  17115. /**
  17116. * 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)
  17117. * Note: This only is supported when using an emitter of type Mesh
  17118. */
  17119. inheritDirection: boolean;
  17120. /**
  17121. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17122. */
  17123. inheritedVelocityAmount: number;
  17124. /**
  17125. * Creates a sub emitter
  17126. * @param particleSystem the particle system to be used by the sub emitter
  17127. */
  17128. constructor(
  17129. /**
  17130. * the particle system to be used by the sub emitter
  17131. */
  17132. particleSystem: ParticleSystem);
  17133. /**
  17134. * Clones the sub emitter
  17135. * @returns the cloned sub emitter
  17136. */
  17137. clone(): SubEmitter;
  17138. /**
  17139. * Serialize current object to a JSON object
  17140. * @returns the serialized object
  17141. */
  17142. serialize(): any;
  17143. /** @hidden */
  17144. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17145. /**
  17146. * Creates a new SubEmitter from a serialized JSON version
  17147. * @param serializationObject defines the JSON object to read from
  17148. * @param scene defines the hosting scene
  17149. * @param rootUrl defines the rootUrl for data loading
  17150. * @returns a new SubEmitter
  17151. */
  17152. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17153. /** Release associated resources */
  17154. dispose(): void;
  17155. }
  17156. }
  17157. declare module BABYLON {
  17158. /** @hidden */
  17159. export var clipPlaneFragmentDeclaration: {
  17160. name: string;
  17161. shader: string;
  17162. };
  17163. }
  17164. declare module BABYLON {
  17165. /** @hidden */
  17166. export var imageProcessingDeclaration: {
  17167. name: string;
  17168. shader: string;
  17169. };
  17170. }
  17171. declare module BABYLON {
  17172. /** @hidden */
  17173. export var imageProcessingFunctions: {
  17174. name: string;
  17175. shader: string;
  17176. };
  17177. }
  17178. declare module BABYLON {
  17179. /** @hidden */
  17180. export var clipPlaneFragment: {
  17181. name: string;
  17182. shader: string;
  17183. };
  17184. }
  17185. declare module BABYLON {
  17186. /** @hidden */
  17187. export var particlesPixelShader: {
  17188. name: string;
  17189. shader: string;
  17190. };
  17191. }
  17192. declare module BABYLON {
  17193. /** @hidden */
  17194. export var clipPlaneVertexDeclaration: {
  17195. name: string;
  17196. shader: string;
  17197. };
  17198. }
  17199. declare module BABYLON {
  17200. /** @hidden */
  17201. export var clipPlaneVertex: {
  17202. name: string;
  17203. shader: string;
  17204. };
  17205. }
  17206. declare module BABYLON {
  17207. /** @hidden */
  17208. export var particlesVertexShader: {
  17209. name: string;
  17210. shader: string;
  17211. };
  17212. }
  17213. declare module BABYLON {
  17214. /**
  17215. * This represents a particle system in Babylon.
  17216. * 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.
  17217. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17218. * @example https://doc.babylonjs.com/babylon101/particles
  17219. */
  17220. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17221. /**
  17222. * Billboard mode will only apply to Y axis
  17223. */
  17224. static readonly BILLBOARDMODE_Y: number;
  17225. /**
  17226. * Billboard mode will apply to all axes
  17227. */
  17228. static readonly BILLBOARDMODE_ALL: number;
  17229. /**
  17230. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17231. */
  17232. static readonly BILLBOARDMODE_STRETCHED: number;
  17233. /**
  17234. * This function can be defined to provide custom update for active particles.
  17235. * This function will be called instead of regular update (age, position, color, etc.).
  17236. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17237. */
  17238. updateFunction: (particles: Particle[]) => void;
  17239. private _emitterWorldMatrix;
  17240. /**
  17241. * This function can be defined to specify initial direction for every new particle.
  17242. * It by default use the emitterType defined function
  17243. */
  17244. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17245. /**
  17246. * This function can be defined to specify initial position for every new particle.
  17247. * It by default use the emitterType defined function
  17248. */
  17249. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17250. /**
  17251. * @hidden
  17252. */
  17253. _inheritedVelocityOffset: Vector3;
  17254. /**
  17255. * An event triggered when the system is disposed
  17256. */
  17257. onDisposeObservable: Observable<ParticleSystem>;
  17258. private _onDisposeObserver;
  17259. /**
  17260. * Sets a callback that will be triggered when the system is disposed
  17261. */
  17262. onDispose: () => void;
  17263. private _particles;
  17264. private _epsilon;
  17265. private _capacity;
  17266. private _stockParticles;
  17267. private _newPartsExcess;
  17268. private _vertexData;
  17269. private _vertexBuffer;
  17270. private _vertexBuffers;
  17271. private _spriteBuffer;
  17272. private _indexBuffer;
  17273. private _effect;
  17274. private _customEffect;
  17275. private _cachedDefines;
  17276. private _scaledColorStep;
  17277. private _colorDiff;
  17278. private _scaledDirection;
  17279. private _scaledGravity;
  17280. private _currentRenderId;
  17281. private _alive;
  17282. private _useInstancing;
  17283. private _started;
  17284. private _stopped;
  17285. private _actualFrame;
  17286. private _scaledUpdateSpeed;
  17287. private _vertexBufferSize;
  17288. /** @hidden */
  17289. _currentEmitRateGradient: Nullable<FactorGradient>;
  17290. /** @hidden */
  17291. _currentEmitRate1: number;
  17292. /** @hidden */
  17293. _currentEmitRate2: number;
  17294. /** @hidden */
  17295. _currentStartSizeGradient: Nullable<FactorGradient>;
  17296. /** @hidden */
  17297. _currentStartSize1: number;
  17298. /** @hidden */
  17299. _currentStartSize2: number;
  17300. private readonly _rawTextureWidth;
  17301. private _rampGradientsTexture;
  17302. private _useRampGradients;
  17303. /** Gets or sets a boolean indicating that ramp gradients must be used
  17304. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17305. */
  17306. useRampGradients: boolean;
  17307. /**
  17308. * 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.
  17309. * 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: [])
  17310. */
  17311. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17312. private _subEmitters;
  17313. /**
  17314. * @hidden
  17315. * If the particle systems emitter should be disposed when the particle system is disposed
  17316. */
  17317. _disposeEmitterOnDispose: boolean;
  17318. /**
  17319. * The current active Sub-systems, this property is used by the root particle system only.
  17320. */
  17321. activeSubSystems: Array<ParticleSystem>;
  17322. private _rootParticleSystem;
  17323. /**
  17324. * Gets the current list of active particles
  17325. */
  17326. readonly particles: Particle[];
  17327. /**
  17328. * Returns the string "ParticleSystem"
  17329. * @returns a string containing the class name
  17330. */
  17331. getClassName(): string;
  17332. /**
  17333. * Instantiates a particle system.
  17334. * 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.
  17335. * @param name The name of the particle system
  17336. * @param capacity The max number of particles alive at the same time
  17337. * @param scene The scene the particle system belongs to
  17338. * @param customEffect a custom effect used to change the way particles are rendered by default
  17339. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17340. * @param epsilon Offset used to render the particles
  17341. */
  17342. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17343. private _addFactorGradient;
  17344. private _removeFactorGradient;
  17345. /**
  17346. * Adds a new life time gradient
  17347. * @param gradient defines the gradient to use (between 0 and 1)
  17348. * @param factor defines the life time factor to affect to the specified gradient
  17349. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17350. * @returns the current particle system
  17351. */
  17352. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17353. /**
  17354. * Remove a specific life time gradient
  17355. * @param gradient defines the gradient to remove
  17356. * @returns the current particle system
  17357. */
  17358. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17359. /**
  17360. * Adds a new size gradient
  17361. * @param gradient defines the gradient to use (between 0 and 1)
  17362. * @param factor defines the size factor to affect to the specified gradient
  17363. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17364. * @returns the current particle system
  17365. */
  17366. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17367. /**
  17368. * Remove a specific size gradient
  17369. * @param gradient defines the gradient to remove
  17370. * @returns the current particle system
  17371. */
  17372. removeSizeGradient(gradient: number): IParticleSystem;
  17373. /**
  17374. * Adds a new color remap gradient
  17375. * @param gradient defines the gradient to use (between 0 and 1)
  17376. * @param min defines the color remap minimal range
  17377. * @param max defines the color remap maximal range
  17378. * @returns the current particle system
  17379. */
  17380. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17381. /**
  17382. * Remove a specific color remap gradient
  17383. * @param gradient defines the gradient to remove
  17384. * @returns the current particle system
  17385. */
  17386. removeColorRemapGradient(gradient: number): IParticleSystem;
  17387. /**
  17388. * Adds a new alpha remap gradient
  17389. * @param gradient defines the gradient to use (between 0 and 1)
  17390. * @param min defines the alpha remap minimal range
  17391. * @param max defines the alpha remap maximal range
  17392. * @returns the current particle system
  17393. */
  17394. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17395. /**
  17396. * Remove a specific alpha remap gradient
  17397. * @param gradient defines the gradient to remove
  17398. * @returns the current particle system
  17399. */
  17400. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17401. /**
  17402. * Adds a new angular speed gradient
  17403. * @param gradient defines the gradient to use (between 0 and 1)
  17404. * @param factor defines the angular speed to affect to the specified gradient
  17405. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17406. * @returns the current particle system
  17407. */
  17408. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17409. /**
  17410. * Remove a specific angular speed gradient
  17411. * @param gradient defines the gradient to remove
  17412. * @returns the current particle system
  17413. */
  17414. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17415. /**
  17416. * Adds a new velocity gradient
  17417. * @param gradient defines the gradient to use (between 0 and 1)
  17418. * @param factor defines the velocity to affect to the specified gradient
  17419. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17420. * @returns the current particle system
  17421. */
  17422. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17423. /**
  17424. * Remove a specific velocity gradient
  17425. * @param gradient defines the gradient to remove
  17426. * @returns the current particle system
  17427. */
  17428. removeVelocityGradient(gradient: number): IParticleSystem;
  17429. /**
  17430. * Adds a new limit velocity gradient
  17431. * @param gradient defines the gradient to use (between 0 and 1)
  17432. * @param factor defines the limit velocity value to affect to the specified gradient
  17433. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17434. * @returns the current particle system
  17435. */
  17436. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17437. /**
  17438. * Remove a specific limit velocity gradient
  17439. * @param gradient defines the gradient to remove
  17440. * @returns the current particle system
  17441. */
  17442. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17443. /**
  17444. * Adds a new drag gradient
  17445. * @param gradient defines the gradient to use (between 0 and 1)
  17446. * @param factor defines the drag value to affect to the specified gradient
  17447. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17448. * @returns the current particle system
  17449. */
  17450. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17451. /**
  17452. * Remove a specific drag gradient
  17453. * @param gradient defines the gradient to remove
  17454. * @returns the current particle system
  17455. */
  17456. removeDragGradient(gradient: number): IParticleSystem;
  17457. /**
  17458. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17459. * @param gradient defines the gradient to use (between 0 and 1)
  17460. * @param factor defines the emit rate value to affect to the specified gradient
  17461. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17462. * @returns the current particle system
  17463. */
  17464. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17465. /**
  17466. * Remove a specific emit rate gradient
  17467. * @param gradient defines the gradient to remove
  17468. * @returns the current particle system
  17469. */
  17470. removeEmitRateGradient(gradient: number): IParticleSystem;
  17471. /**
  17472. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17473. * @param gradient defines the gradient to use (between 0 and 1)
  17474. * @param factor defines the start size value to affect to the specified gradient
  17475. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17476. * @returns the current particle system
  17477. */
  17478. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17479. /**
  17480. * Remove a specific start size gradient
  17481. * @param gradient defines the gradient to remove
  17482. * @returns the current particle system
  17483. */
  17484. removeStartSizeGradient(gradient: number): IParticleSystem;
  17485. private _createRampGradientTexture;
  17486. /**
  17487. * Gets the current list of ramp gradients.
  17488. * You must use addRampGradient and removeRampGradient to udpate this list
  17489. * @returns the list of ramp gradients
  17490. */
  17491. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17492. /**
  17493. * Adds a new ramp gradient used to remap particle colors
  17494. * @param gradient defines the gradient to use (between 0 and 1)
  17495. * @param color defines the color to affect to the specified gradient
  17496. * @returns the current particle system
  17497. */
  17498. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17499. /**
  17500. * Remove a specific ramp gradient
  17501. * @param gradient defines the gradient to remove
  17502. * @returns the current particle system
  17503. */
  17504. removeRampGradient(gradient: number): ParticleSystem;
  17505. /**
  17506. * Adds a new color gradient
  17507. * @param gradient defines the gradient to use (between 0 and 1)
  17508. * @param color1 defines the color to affect to the specified gradient
  17509. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17510. * @returns this particle system
  17511. */
  17512. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17513. /**
  17514. * Remove a specific color gradient
  17515. * @param gradient defines the gradient to remove
  17516. * @returns this particle system
  17517. */
  17518. removeColorGradient(gradient: number): IParticleSystem;
  17519. private _fetchR;
  17520. protected _reset(): void;
  17521. private _resetEffect;
  17522. private _createVertexBuffers;
  17523. private _createIndexBuffer;
  17524. /**
  17525. * Gets the maximum number of particles active at the same time.
  17526. * @returns The max number of active particles.
  17527. */
  17528. getCapacity(): number;
  17529. /**
  17530. * Gets whether there are still active particles in the system.
  17531. * @returns True if it is alive, otherwise false.
  17532. */
  17533. isAlive(): boolean;
  17534. /**
  17535. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17536. * @returns True if it has been started, otherwise false.
  17537. */
  17538. isStarted(): boolean;
  17539. private _prepareSubEmitterInternalArray;
  17540. /**
  17541. * Starts the particle system and begins to emit
  17542. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17543. */
  17544. start(delay?: number): void;
  17545. /**
  17546. * Stops the particle system.
  17547. * @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.
  17548. */
  17549. stop(stopSubEmitters?: boolean): void;
  17550. /**
  17551. * Remove all active particles
  17552. */
  17553. reset(): void;
  17554. /**
  17555. * @hidden (for internal use only)
  17556. */
  17557. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17558. /**
  17559. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17560. * Its lifetime will start back at 0.
  17561. */
  17562. recycleParticle: (particle: Particle) => void;
  17563. private _stopSubEmitters;
  17564. private _createParticle;
  17565. private _removeFromRoot;
  17566. private _emitFromParticle;
  17567. private _update;
  17568. /** @hidden */
  17569. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17570. /** @hidden */
  17571. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17572. /** @hidden */
  17573. private _getEffect;
  17574. /**
  17575. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17576. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17577. */
  17578. animate(preWarmOnly?: boolean): void;
  17579. private _appendParticleVertices;
  17580. /**
  17581. * Rebuilds the particle system.
  17582. */
  17583. rebuild(): void;
  17584. /**
  17585. * Is this system ready to be used/rendered
  17586. * @return true if the system is ready
  17587. */
  17588. isReady(): boolean;
  17589. private _render;
  17590. /**
  17591. * Renders the particle system in its current state.
  17592. * @returns the current number of particles
  17593. */
  17594. render(): number;
  17595. /**
  17596. * Disposes the particle system and free the associated resources
  17597. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17598. */
  17599. dispose(disposeTexture?: boolean): void;
  17600. /**
  17601. * Clones the particle system.
  17602. * @param name The name of the cloned object
  17603. * @param newEmitter The new emitter to use
  17604. * @returns the cloned particle system
  17605. */
  17606. clone(name: string, newEmitter: any): ParticleSystem;
  17607. /**
  17608. * Serializes the particle system to a JSON object.
  17609. * @returns the JSON object
  17610. */
  17611. serialize(): any;
  17612. /** @hidden */
  17613. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17614. /** @hidden */
  17615. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17616. /**
  17617. * Parses a JSON object to create a particle system.
  17618. * @param parsedParticleSystem The JSON object to parse
  17619. * @param scene The scene to create the particle system in
  17620. * @param rootUrl The root url to use to load external dependencies like texture
  17621. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17622. * @returns the Parsed particle system
  17623. */
  17624. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17625. }
  17626. }
  17627. declare module BABYLON {
  17628. /**
  17629. * A particle represents one of the element emitted by a particle system.
  17630. * This is mainly define by its coordinates, direction, velocity and age.
  17631. */
  17632. export class Particle {
  17633. /**
  17634. * The particle system the particle belongs to.
  17635. */
  17636. particleSystem: ParticleSystem;
  17637. private static _Count;
  17638. /**
  17639. * Unique ID of the particle
  17640. */
  17641. id: number;
  17642. /**
  17643. * The world position of the particle in the scene.
  17644. */
  17645. position: Vector3;
  17646. /**
  17647. * The world direction of the particle in the scene.
  17648. */
  17649. direction: Vector3;
  17650. /**
  17651. * The color of the particle.
  17652. */
  17653. color: Color4;
  17654. /**
  17655. * The color change of the particle per step.
  17656. */
  17657. colorStep: Color4;
  17658. /**
  17659. * Defines how long will the life of the particle be.
  17660. */
  17661. lifeTime: number;
  17662. /**
  17663. * The current age of the particle.
  17664. */
  17665. age: number;
  17666. /**
  17667. * The current size of the particle.
  17668. */
  17669. size: number;
  17670. /**
  17671. * The current scale of the particle.
  17672. */
  17673. scale: Vector2;
  17674. /**
  17675. * The current angle of the particle.
  17676. */
  17677. angle: number;
  17678. /**
  17679. * Defines how fast is the angle changing.
  17680. */
  17681. angularSpeed: number;
  17682. /**
  17683. * Defines the cell index used by the particle to be rendered from a sprite.
  17684. */
  17685. cellIndex: number;
  17686. /**
  17687. * The information required to support color remapping
  17688. */
  17689. remapData: Vector4;
  17690. /** @hidden */
  17691. _randomCellOffset?: number;
  17692. /** @hidden */
  17693. _initialDirection: Nullable<Vector3>;
  17694. /** @hidden */
  17695. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17696. /** @hidden */
  17697. _initialStartSpriteCellID: number;
  17698. /** @hidden */
  17699. _initialEndSpriteCellID: number;
  17700. /** @hidden */
  17701. _currentColorGradient: Nullable<ColorGradient>;
  17702. /** @hidden */
  17703. _currentColor1: Color4;
  17704. /** @hidden */
  17705. _currentColor2: Color4;
  17706. /** @hidden */
  17707. _currentSizeGradient: Nullable<FactorGradient>;
  17708. /** @hidden */
  17709. _currentSize1: number;
  17710. /** @hidden */
  17711. _currentSize2: number;
  17712. /** @hidden */
  17713. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17714. /** @hidden */
  17715. _currentAngularSpeed1: number;
  17716. /** @hidden */
  17717. _currentAngularSpeed2: number;
  17718. /** @hidden */
  17719. _currentVelocityGradient: Nullable<FactorGradient>;
  17720. /** @hidden */
  17721. _currentVelocity1: number;
  17722. /** @hidden */
  17723. _currentVelocity2: number;
  17724. /** @hidden */
  17725. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17726. /** @hidden */
  17727. _currentLimitVelocity1: number;
  17728. /** @hidden */
  17729. _currentLimitVelocity2: number;
  17730. /** @hidden */
  17731. _currentDragGradient: Nullable<FactorGradient>;
  17732. /** @hidden */
  17733. _currentDrag1: number;
  17734. /** @hidden */
  17735. _currentDrag2: number;
  17736. /** @hidden */
  17737. _randomNoiseCoordinates1: Vector3;
  17738. /** @hidden */
  17739. _randomNoiseCoordinates2: Vector3;
  17740. /**
  17741. * Creates a new instance Particle
  17742. * @param particleSystem the particle system the particle belongs to
  17743. */
  17744. constructor(
  17745. /**
  17746. * The particle system the particle belongs to.
  17747. */
  17748. particleSystem: ParticleSystem);
  17749. private updateCellInfoFromSystem;
  17750. /**
  17751. * Defines how the sprite cell index is updated for the particle
  17752. */
  17753. updateCellIndex(): void;
  17754. /** @hidden */
  17755. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17756. /** @hidden */
  17757. _inheritParticleInfoToSubEmitters(): void;
  17758. /** @hidden */
  17759. _reset(): void;
  17760. /**
  17761. * Copy the properties of particle to another one.
  17762. * @param other the particle to copy the information to.
  17763. */
  17764. copyTo(other: Particle): void;
  17765. }
  17766. }
  17767. declare module BABYLON {
  17768. /**
  17769. * Particle emitter represents a volume emitting particles.
  17770. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17771. */
  17772. export interface IParticleEmitterType {
  17773. /**
  17774. * Called by the particle System when the direction is computed for the created particle.
  17775. * @param worldMatrix is the world matrix of the particle system
  17776. * @param directionToUpdate is the direction vector to update with the result
  17777. * @param particle is the particle we are computed the direction for
  17778. */
  17779. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17780. /**
  17781. * Called by the particle System when the position is computed for the created particle.
  17782. * @param worldMatrix is the world matrix of the particle system
  17783. * @param positionToUpdate is the position vector to update with the result
  17784. * @param particle is the particle we are computed the position for
  17785. */
  17786. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17787. /**
  17788. * Clones the current emitter and returns a copy of it
  17789. * @returns the new emitter
  17790. */
  17791. clone(): IParticleEmitterType;
  17792. /**
  17793. * Called by the GPUParticleSystem to setup the update shader
  17794. * @param effect defines the update shader
  17795. */
  17796. applyToShader(effect: Effect): void;
  17797. /**
  17798. * Returns a string to use to update the GPU particles update shader
  17799. * @returns the effect defines string
  17800. */
  17801. getEffectDefines(): string;
  17802. /**
  17803. * Returns a string representing the class name
  17804. * @returns a string containing the class name
  17805. */
  17806. getClassName(): string;
  17807. /**
  17808. * Serializes the particle system to a JSON object.
  17809. * @returns the JSON object
  17810. */
  17811. serialize(): any;
  17812. /**
  17813. * Parse properties from a JSON object
  17814. * @param serializationObject defines the JSON object
  17815. */
  17816. parse(serializationObject: any): void;
  17817. }
  17818. }
  17819. declare module BABYLON {
  17820. /**
  17821. * Particle emitter emitting particles from the inside of a box.
  17822. * It emits the particles randomly between 2 given directions.
  17823. */
  17824. export class BoxParticleEmitter implements IParticleEmitterType {
  17825. /**
  17826. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17827. */
  17828. direction1: Vector3;
  17829. /**
  17830. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17831. */
  17832. direction2: Vector3;
  17833. /**
  17834. * 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.
  17835. */
  17836. minEmitBox: Vector3;
  17837. /**
  17838. * 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.
  17839. */
  17840. maxEmitBox: Vector3;
  17841. /**
  17842. * Creates a new instance BoxParticleEmitter
  17843. */
  17844. constructor();
  17845. /**
  17846. * Called by the particle System when the direction is computed for the created particle.
  17847. * @param worldMatrix is the world matrix of the particle system
  17848. * @param directionToUpdate is the direction vector to update with the result
  17849. * @param particle is the particle we are computed the direction for
  17850. */
  17851. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17852. /**
  17853. * Called by the particle System when the position is computed for the created particle.
  17854. * @param worldMatrix is the world matrix of the particle system
  17855. * @param positionToUpdate is the position vector to update with the result
  17856. * @param particle is the particle we are computed the position for
  17857. */
  17858. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17859. /**
  17860. * Clones the current emitter and returns a copy of it
  17861. * @returns the new emitter
  17862. */
  17863. clone(): BoxParticleEmitter;
  17864. /**
  17865. * Called by the GPUParticleSystem to setup the update shader
  17866. * @param effect defines the update shader
  17867. */
  17868. applyToShader(effect: Effect): void;
  17869. /**
  17870. * Returns a string to use to update the GPU particles update shader
  17871. * @returns a string containng the defines string
  17872. */
  17873. getEffectDefines(): string;
  17874. /**
  17875. * Returns the string "BoxParticleEmitter"
  17876. * @returns a string containing the class name
  17877. */
  17878. getClassName(): string;
  17879. /**
  17880. * Serializes the particle system to a JSON object.
  17881. * @returns the JSON object
  17882. */
  17883. serialize(): any;
  17884. /**
  17885. * Parse properties from a JSON object
  17886. * @param serializationObject defines the JSON object
  17887. */
  17888. parse(serializationObject: any): void;
  17889. }
  17890. }
  17891. declare module BABYLON {
  17892. /**
  17893. * Particle emitter emitting particles from the inside of a cone.
  17894. * It emits the particles alongside the cone volume from the base to the particle.
  17895. * The emission direction might be randomized.
  17896. */
  17897. export class ConeParticleEmitter implements IParticleEmitterType {
  17898. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17899. directionRandomizer: number;
  17900. private _radius;
  17901. private _angle;
  17902. private _height;
  17903. /**
  17904. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17905. */
  17906. radiusRange: number;
  17907. /**
  17908. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17909. */
  17910. heightRange: number;
  17911. /**
  17912. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17913. */
  17914. emitFromSpawnPointOnly: boolean;
  17915. /**
  17916. * Gets or sets the radius of the emission cone
  17917. */
  17918. radius: number;
  17919. /**
  17920. * Gets or sets the angle of the emission cone
  17921. */
  17922. angle: number;
  17923. private _buildHeight;
  17924. /**
  17925. * Creates a new instance ConeParticleEmitter
  17926. * @param radius the radius of the emission cone (1 by default)
  17927. * @param angle the cone base angle (PI by default)
  17928. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17929. */
  17930. constructor(radius?: number, angle?: number,
  17931. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17932. directionRandomizer?: number);
  17933. /**
  17934. * Called by the particle System when the direction is computed for the created particle.
  17935. * @param worldMatrix is the world matrix of the particle system
  17936. * @param directionToUpdate is the direction vector to update with the result
  17937. * @param particle is the particle we are computed the direction for
  17938. */
  17939. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17940. /**
  17941. * Called by the particle System when the position is computed for the created particle.
  17942. * @param worldMatrix is the world matrix of the particle system
  17943. * @param positionToUpdate is the position vector to update with the result
  17944. * @param particle is the particle we are computed the position for
  17945. */
  17946. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17947. /**
  17948. * Clones the current emitter and returns a copy of it
  17949. * @returns the new emitter
  17950. */
  17951. clone(): ConeParticleEmitter;
  17952. /**
  17953. * Called by the GPUParticleSystem to setup the update shader
  17954. * @param effect defines the update shader
  17955. */
  17956. applyToShader(effect: Effect): void;
  17957. /**
  17958. * Returns a string to use to update the GPU particles update shader
  17959. * @returns a string containng the defines string
  17960. */
  17961. getEffectDefines(): string;
  17962. /**
  17963. * Returns the string "ConeParticleEmitter"
  17964. * @returns a string containing the class name
  17965. */
  17966. getClassName(): string;
  17967. /**
  17968. * Serializes the particle system to a JSON object.
  17969. * @returns the JSON object
  17970. */
  17971. serialize(): any;
  17972. /**
  17973. * Parse properties from a JSON object
  17974. * @param serializationObject defines the JSON object
  17975. */
  17976. parse(serializationObject: any): void;
  17977. }
  17978. }
  17979. declare module BABYLON {
  17980. /**
  17981. * Particle emitter emitting particles from the inside of a cylinder.
  17982. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17983. */
  17984. export class CylinderParticleEmitter implements IParticleEmitterType {
  17985. /**
  17986. * The radius of the emission cylinder.
  17987. */
  17988. radius: number;
  17989. /**
  17990. * The height of the emission cylinder.
  17991. */
  17992. height: number;
  17993. /**
  17994. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17995. */
  17996. radiusRange: number;
  17997. /**
  17998. * How much to randomize the particle direction [0-1].
  17999. */
  18000. directionRandomizer: number;
  18001. /**
  18002. * Creates a new instance CylinderParticleEmitter
  18003. * @param radius the radius of the emission cylinder (1 by default)
  18004. * @param height the height of the emission cylinder (1 by default)
  18005. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18006. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18007. */
  18008. constructor(
  18009. /**
  18010. * The radius of the emission cylinder.
  18011. */
  18012. radius?: number,
  18013. /**
  18014. * The height of the emission cylinder.
  18015. */
  18016. height?: number,
  18017. /**
  18018. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18019. */
  18020. radiusRange?: number,
  18021. /**
  18022. * How much to randomize the particle direction [0-1].
  18023. */
  18024. directionRandomizer?: number);
  18025. /**
  18026. * Called by the particle System when the direction is computed for the created particle.
  18027. * @param worldMatrix is the world matrix of the particle system
  18028. * @param directionToUpdate is the direction vector to update with the result
  18029. * @param particle is the particle we are computed the direction for
  18030. */
  18031. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18032. /**
  18033. * Called by the particle System when the position is computed for the created particle.
  18034. * @param worldMatrix is the world matrix of the particle system
  18035. * @param positionToUpdate is the position vector to update with the result
  18036. * @param particle is the particle we are computed the position for
  18037. */
  18038. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18039. /**
  18040. * Clones the current emitter and returns a copy of it
  18041. * @returns the new emitter
  18042. */
  18043. clone(): CylinderParticleEmitter;
  18044. /**
  18045. * Called by the GPUParticleSystem to setup the update shader
  18046. * @param effect defines the update shader
  18047. */
  18048. applyToShader(effect: Effect): void;
  18049. /**
  18050. * Returns a string to use to update the GPU particles update shader
  18051. * @returns a string containng the defines string
  18052. */
  18053. getEffectDefines(): string;
  18054. /**
  18055. * Returns the string "CylinderParticleEmitter"
  18056. * @returns a string containing the class name
  18057. */
  18058. getClassName(): string;
  18059. /**
  18060. * Serializes the particle system to a JSON object.
  18061. * @returns the JSON object
  18062. */
  18063. serialize(): any;
  18064. /**
  18065. * Parse properties from a JSON object
  18066. * @param serializationObject defines the JSON object
  18067. */
  18068. parse(serializationObject: any): void;
  18069. }
  18070. /**
  18071. * Particle emitter emitting particles from the inside of a cylinder.
  18072. * It emits the particles randomly between two vectors.
  18073. */
  18074. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18075. /**
  18076. * The min limit of the emission direction.
  18077. */
  18078. direction1: Vector3;
  18079. /**
  18080. * The max limit of the emission direction.
  18081. */
  18082. direction2: Vector3;
  18083. /**
  18084. * Creates a new instance CylinderDirectedParticleEmitter
  18085. * @param radius the radius of the emission cylinder (1 by default)
  18086. * @param height the height of the emission cylinder (1 by default)
  18087. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18088. * @param direction1 the min limit of the emission direction (up vector by default)
  18089. * @param direction2 the max limit of the emission direction (up vector by default)
  18090. */
  18091. constructor(radius?: number, height?: number, radiusRange?: number,
  18092. /**
  18093. * The min limit of the emission direction.
  18094. */
  18095. direction1?: Vector3,
  18096. /**
  18097. * The max limit of the emission direction.
  18098. */
  18099. direction2?: Vector3);
  18100. /**
  18101. * Called by the particle System when the direction is computed for the created particle.
  18102. * @param worldMatrix is the world matrix of the particle system
  18103. * @param directionToUpdate is the direction vector to update with the result
  18104. * @param particle is the particle we are computed the direction for
  18105. */
  18106. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18107. /**
  18108. * Clones the current emitter and returns a copy of it
  18109. * @returns the new emitter
  18110. */
  18111. clone(): CylinderDirectedParticleEmitter;
  18112. /**
  18113. * Called by the GPUParticleSystem to setup the update shader
  18114. * @param effect defines the update shader
  18115. */
  18116. applyToShader(effect: Effect): void;
  18117. /**
  18118. * Returns a string to use to update the GPU particles update shader
  18119. * @returns a string containng the defines string
  18120. */
  18121. getEffectDefines(): string;
  18122. /**
  18123. * Returns the string "CylinderDirectedParticleEmitter"
  18124. * @returns a string containing the class name
  18125. */
  18126. getClassName(): string;
  18127. /**
  18128. * Serializes the particle system to a JSON object.
  18129. * @returns the JSON object
  18130. */
  18131. serialize(): any;
  18132. /**
  18133. * Parse properties from a JSON object
  18134. * @param serializationObject defines the JSON object
  18135. */
  18136. parse(serializationObject: any): void;
  18137. }
  18138. }
  18139. declare module BABYLON {
  18140. /**
  18141. * Particle emitter emitting particles from the inside of a hemisphere.
  18142. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18143. */
  18144. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18145. /**
  18146. * The radius of the emission hemisphere.
  18147. */
  18148. radius: number;
  18149. /**
  18150. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18151. */
  18152. radiusRange: number;
  18153. /**
  18154. * How much to randomize the particle direction [0-1].
  18155. */
  18156. directionRandomizer: number;
  18157. /**
  18158. * Creates a new instance HemisphericParticleEmitter
  18159. * @param radius the radius of the emission hemisphere (1 by default)
  18160. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18161. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18162. */
  18163. constructor(
  18164. /**
  18165. * The radius of the emission hemisphere.
  18166. */
  18167. radius?: number,
  18168. /**
  18169. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18170. */
  18171. radiusRange?: number,
  18172. /**
  18173. * How much to randomize the particle direction [0-1].
  18174. */
  18175. directionRandomizer?: number);
  18176. /**
  18177. * Called by the particle System when the direction is computed for the created particle.
  18178. * @param worldMatrix is the world matrix of the particle system
  18179. * @param directionToUpdate is the direction vector to update with the result
  18180. * @param particle is the particle we are computed the direction for
  18181. */
  18182. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18183. /**
  18184. * Called by the particle System when the position is computed for the created particle.
  18185. * @param worldMatrix is the world matrix of the particle system
  18186. * @param positionToUpdate is the position vector to update with the result
  18187. * @param particle is the particle we are computed the position for
  18188. */
  18189. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18190. /**
  18191. * Clones the current emitter and returns a copy of it
  18192. * @returns the new emitter
  18193. */
  18194. clone(): HemisphericParticleEmitter;
  18195. /**
  18196. * Called by the GPUParticleSystem to setup the update shader
  18197. * @param effect defines the update shader
  18198. */
  18199. applyToShader(effect: Effect): void;
  18200. /**
  18201. * Returns a string to use to update the GPU particles update shader
  18202. * @returns a string containng the defines string
  18203. */
  18204. getEffectDefines(): string;
  18205. /**
  18206. * Returns the string "HemisphericParticleEmitter"
  18207. * @returns a string containing the class name
  18208. */
  18209. getClassName(): string;
  18210. /**
  18211. * Serializes the particle system to a JSON object.
  18212. * @returns the JSON object
  18213. */
  18214. serialize(): any;
  18215. /**
  18216. * Parse properties from a JSON object
  18217. * @param serializationObject defines the JSON object
  18218. */
  18219. parse(serializationObject: any): void;
  18220. }
  18221. }
  18222. declare module BABYLON {
  18223. /**
  18224. * Particle emitter emitting particles from a point.
  18225. * It emits the particles randomly between 2 given directions.
  18226. */
  18227. export class PointParticleEmitter implements IParticleEmitterType {
  18228. /**
  18229. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18230. */
  18231. direction1: Vector3;
  18232. /**
  18233. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18234. */
  18235. direction2: Vector3;
  18236. /**
  18237. * Creates a new instance PointParticleEmitter
  18238. */
  18239. constructor();
  18240. /**
  18241. * Called by the particle System when the direction is computed for the created particle.
  18242. * @param worldMatrix is the world matrix of the particle system
  18243. * @param directionToUpdate is the direction vector to update with the result
  18244. * @param particle is the particle we are computed the direction for
  18245. */
  18246. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18247. /**
  18248. * Called by the particle System when the position is computed for the created particle.
  18249. * @param worldMatrix is the world matrix of the particle system
  18250. * @param positionToUpdate is the position vector to update with the result
  18251. * @param particle is the particle we are computed the position for
  18252. */
  18253. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18254. /**
  18255. * Clones the current emitter and returns a copy of it
  18256. * @returns the new emitter
  18257. */
  18258. clone(): PointParticleEmitter;
  18259. /**
  18260. * Called by the GPUParticleSystem to setup the update shader
  18261. * @param effect defines the update shader
  18262. */
  18263. applyToShader(effect: Effect): void;
  18264. /**
  18265. * Returns a string to use to update the GPU particles update shader
  18266. * @returns a string containng the defines string
  18267. */
  18268. getEffectDefines(): string;
  18269. /**
  18270. * Returns the string "PointParticleEmitter"
  18271. * @returns a string containing the class name
  18272. */
  18273. getClassName(): string;
  18274. /**
  18275. * Serializes the particle system to a JSON object.
  18276. * @returns the JSON object
  18277. */
  18278. serialize(): any;
  18279. /**
  18280. * Parse properties from a JSON object
  18281. * @param serializationObject defines the JSON object
  18282. */
  18283. parse(serializationObject: any): void;
  18284. }
  18285. }
  18286. declare module BABYLON {
  18287. /**
  18288. * Particle emitter emitting particles from the inside of a sphere.
  18289. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18290. */
  18291. export class SphereParticleEmitter implements IParticleEmitterType {
  18292. /**
  18293. * The radius of the emission sphere.
  18294. */
  18295. radius: number;
  18296. /**
  18297. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18298. */
  18299. radiusRange: number;
  18300. /**
  18301. * How much to randomize the particle direction [0-1].
  18302. */
  18303. directionRandomizer: number;
  18304. /**
  18305. * Creates a new instance SphereParticleEmitter
  18306. * @param radius the radius of the emission sphere (1 by default)
  18307. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18308. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18309. */
  18310. constructor(
  18311. /**
  18312. * The radius of the emission sphere.
  18313. */
  18314. radius?: number,
  18315. /**
  18316. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18317. */
  18318. radiusRange?: number,
  18319. /**
  18320. * How much to randomize the particle direction [0-1].
  18321. */
  18322. directionRandomizer?: number);
  18323. /**
  18324. * Called by the particle System when the direction is computed for the created particle.
  18325. * @param worldMatrix is the world matrix of the particle system
  18326. * @param directionToUpdate is the direction vector to update with the result
  18327. * @param particle is the particle we are computed the direction for
  18328. */
  18329. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18330. /**
  18331. * Called by the particle System when the position is computed for the created particle.
  18332. * @param worldMatrix is the world matrix of the particle system
  18333. * @param positionToUpdate is the position vector to update with the result
  18334. * @param particle is the particle we are computed the position for
  18335. */
  18336. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18337. /**
  18338. * Clones the current emitter and returns a copy of it
  18339. * @returns the new emitter
  18340. */
  18341. clone(): SphereParticleEmitter;
  18342. /**
  18343. * Called by the GPUParticleSystem to setup the update shader
  18344. * @param effect defines the update shader
  18345. */
  18346. applyToShader(effect: Effect): void;
  18347. /**
  18348. * Returns a string to use to update the GPU particles update shader
  18349. * @returns a string containng the defines string
  18350. */
  18351. getEffectDefines(): string;
  18352. /**
  18353. * Returns the string "SphereParticleEmitter"
  18354. * @returns a string containing the class name
  18355. */
  18356. getClassName(): string;
  18357. /**
  18358. * Serializes the particle system to a JSON object.
  18359. * @returns the JSON object
  18360. */
  18361. serialize(): any;
  18362. /**
  18363. * Parse properties from a JSON object
  18364. * @param serializationObject defines the JSON object
  18365. */
  18366. parse(serializationObject: any): void;
  18367. }
  18368. /**
  18369. * Particle emitter emitting particles from the inside of a sphere.
  18370. * It emits the particles randomly between two vectors.
  18371. */
  18372. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18373. /**
  18374. * The min limit of the emission direction.
  18375. */
  18376. direction1: Vector3;
  18377. /**
  18378. * The max limit of the emission direction.
  18379. */
  18380. direction2: Vector3;
  18381. /**
  18382. * Creates a new instance SphereDirectedParticleEmitter
  18383. * @param radius the radius of the emission sphere (1 by default)
  18384. * @param direction1 the min limit of the emission direction (up vector by default)
  18385. * @param direction2 the max limit of the emission direction (up vector by default)
  18386. */
  18387. constructor(radius?: number,
  18388. /**
  18389. * The min limit of the emission direction.
  18390. */
  18391. direction1?: Vector3,
  18392. /**
  18393. * The max limit of the emission direction.
  18394. */
  18395. direction2?: Vector3);
  18396. /**
  18397. * Called by the particle System when the direction is computed for the created particle.
  18398. * @param worldMatrix is the world matrix of the particle system
  18399. * @param directionToUpdate is the direction vector to update with the result
  18400. * @param particle is the particle we are computed the direction for
  18401. */
  18402. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18403. /**
  18404. * Clones the current emitter and returns a copy of it
  18405. * @returns the new emitter
  18406. */
  18407. clone(): SphereDirectedParticleEmitter;
  18408. /**
  18409. * Called by the GPUParticleSystem to setup the update shader
  18410. * @param effect defines the update shader
  18411. */
  18412. applyToShader(effect: Effect): void;
  18413. /**
  18414. * Returns a string to use to update the GPU particles update shader
  18415. * @returns a string containng the defines string
  18416. */
  18417. getEffectDefines(): string;
  18418. /**
  18419. * Returns the string "SphereDirectedParticleEmitter"
  18420. * @returns a string containing the class name
  18421. */
  18422. getClassName(): string;
  18423. /**
  18424. * Serializes the particle system to a JSON object.
  18425. * @returns the JSON object
  18426. */
  18427. serialize(): any;
  18428. /**
  18429. * Parse properties from a JSON object
  18430. * @param serializationObject defines the JSON object
  18431. */
  18432. parse(serializationObject: any): void;
  18433. }
  18434. }
  18435. declare module BABYLON {
  18436. /**
  18437. * Interface representing a particle system in Babylon.js.
  18438. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18439. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18440. */
  18441. export interface IParticleSystem {
  18442. /**
  18443. * List of animations used by the particle system.
  18444. */
  18445. animations: Animation[];
  18446. /**
  18447. * The id of the Particle system.
  18448. */
  18449. id: string;
  18450. /**
  18451. * The name of the Particle system.
  18452. */
  18453. name: string;
  18454. /**
  18455. * The emitter represents the Mesh or position we are attaching the particle system to.
  18456. */
  18457. emitter: Nullable<AbstractMesh | Vector3>;
  18458. /**
  18459. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18460. */
  18461. isBillboardBased: boolean;
  18462. /**
  18463. * The rendering group used by the Particle system to chose when to render.
  18464. */
  18465. renderingGroupId: number;
  18466. /**
  18467. * The layer mask we are rendering the particles through.
  18468. */
  18469. layerMask: number;
  18470. /**
  18471. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18472. */
  18473. updateSpeed: number;
  18474. /**
  18475. * The amount of time the particle system is running (depends of the overall update speed).
  18476. */
  18477. targetStopDuration: number;
  18478. /**
  18479. * The texture used to render each particle. (this can be a spritesheet)
  18480. */
  18481. particleTexture: Nullable<Texture>;
  18482. /**
  18483. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18484. */
  18485. blendMode: number;
  18486. /**
  18487. * Minimum life time of emitting particles.
  18488. */
  18489. minLifeTime: number;
  18490. /**
  18491. * Maximum life time of emitting particles.
  18492. */
  18493. maxLifeTime: number;
  18494. /**
  18495. * Minimum Size of emitting particles.
  18496. */
  18497. minSize: number;
  18498. /**
  18499. * Maximum Size of emitting particles.
  18500. */
  18501. maxSize: number;
  18502. /**
  18503. * Minimum scale of emitting particles on X axis.
  18504. */
  18505. minScaleX: number;
  18506. /**
  18507. * Maximum scale of emitting particles on X axis.
  18508. */
  18509. maxScaleX: number;
  18510. /**
  18511. * Minimum scale of emitting particles on Y axis.
  18512. */
  18513. minScaleY: number;
  18514. /**
  18515. * Maximum scale of emitting particles on Y axis.
  18516. */
  18517. maxScaleY: number;
  18518. /**
  18519. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18520. */
  18521. color1: Color4;
  18522. /**
  18523. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18524. */
  18525. color2: Color4;
  18526. /**
  18527. * Color the particle will have at the end of its lifetime.
  18528. */
  18529. colorDead: Color4;
  18530. /**
  18531. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18532. */
  18533. emitRate: number;
  18534. /**
  18535. * You can use gravity if you want to give an orientation to your particles.
  18536. */
  18537. gravity: Vector3;
  18538. /**
  18539. * Minimum power of emitting particles.
  18540. */
  18541. minEmitPower: number;
  18542. /**
  18543. * Maximum power of emitting particles.
  18544. */
  18545. maxEmitPower: number;
  18546. /**
  18547. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18548. */
  18549. minAngularSpeed: number;
  18550. /**
  18551. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18552. */
  18553. maxAngularSpeed: number;
  18554. /**
  18555. * Gets or sets the minimal initial rotation in radians.
  18556. */
  18557. minInitialRotation: number;
  18558. /**
  18559. * Gets or sets the maximal initial rotation in radians.
  18560. */
  18561. maxInitialRotation: number;
  18562. /**
  18563. * The particle emitter type defines the emitter used by the particle system.
  18564. * It can be for example box, sphere, or cone...
  18565. */
  18566. particleEmitterType: Nullable<IParticleEmitterType>;
  18567. /**
  18568. * Defines the delay in milliseconds before starting the system (0 by default)
  18569. */
  18570. startDelay: number;
  18571. /**
  18572. * 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
  18573. */
  18574. preWarmCycles: number;
  18575. /**
  18576. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18577. */
  18578. preWarmStepOffset: number;
  18579. /**
  18580. * 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)
  18581. */
  18582. spriteCellChangeSpeed: number;
  18583. /**
  18584. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18585. */
  18586. startSpriteCellID: number;
  18587. /**
  18588. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18589. */
  18590. endSpriteCellID: number;
  18591. /**
  18592. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18593. */
  18594. spriteCellWidth: number;
  18595. /**
  18596. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18597. */
  18598. spriteCellHeight: number;
  18599. /**
  18600. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18601. */
  18602. spriteRandomStartCell: boolean;
  18603. /**
  18604. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18605. */
  18606. isAnimationSheetEnabled: boolean;
  18607. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18608. translationPivot: Vector2;
  18609. /**
  18610. * Gets or sets a texture used to add random noise to particle positions
  18611. */
  18612. noiseTexture: Nullable<BaseTexture>;
  18613. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18614. noiseStrength: Vector3;
  18615. /**
  18616. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18617. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18618. */
  18619. billboardMode: number;
  18620. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18621. limitVelocityDamping: number;
  18622. /**
  18623. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18624. */
  18625. beginAnimationOnStart: boolean;
  18626. /**
  18627. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18628. */
  18629. beginAnimationFrom: number;
  18630. /**
  18631. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18632. */
  18633. beginAnimationTo: number;
  18634. /**
  18635. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18636. */
  18637. beginAnimationLoop: boolean;
  18638. /**
  18639. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18640. */
  18641. disposeOnStop: boolean;
  18642. /**
  18643. * Gets the maximum number of particles active at the same time.
  18644. * @returns The max number of active particles.
  18645. */
  18646. getCapacity(): number;
  18647. /**
  18648. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18649. * @returns True if it has been started, otherwise false.
  18650. */
  18651. isStarted(): boolean;
  18652. /**
  18653. * Animates the particle system for this frame.
  18654. */
  18655. animate(): void;
  18656. /**
  18657. * Renders the particle system in its current state.
  18658. * @returns the current number of particles
  18659. */
  18660. render(): number;
  18661. /**
  18662. * Dispose the particle system and frees its associated resources.
  18663. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18664. */
  18665. dispose(disposeTexture?: boolean): void;
  18666. /**
  18667. * Clones the particle system.
  18668. * @param name The name of the cloned object
  18669. * @param newEmitter The new emitter to use
  18670. * @returns the cloned particle system
  18671. */
  18672. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18673. /**
  18674. * Serializes the particle system to a JSON object.
  18675. * @returns the JSON object
  18676. */
  18677. serialize(): any;
  18678. /**
  18679. * Rebuild the particle system
  18680. */
  18681. rebuild(): void;
  18682. /**
  18683. * Starts the particle system and begins to emit
  18684. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18685. */
  18686. start(delay?: number): void;
  18687. /**
  18688. * Stops the particle system.
  18689. */
  18690. stop(): void;
  18691. /**
  18692. * Remove all active particles
  18693. */
  18694. reset(): void;
  18695. /**
  18696. * Is this system ready to be used/rendered
  18697. * @return true if the system is ready
  18698. */
  18699. isReady(): boolean;
  18700. /**
  18701. * Adds a new color gradient
  18702. * @param gradient defines the gradient to use (between 0 and 1)
  18703. * @param color1 defines the color to affect to the specified gradient
  18704. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18705. * @returns the current particle system
  18706. */
  18707. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18708. /**
  18709. * Remove a specific color gradient
  18710. * @param gradient defines the gradient to remove
  18711. * @returns the current particle system
  18712. */
  18713. removeColorGradient(gradient: number): IParticleSystem;
  18714. /**
  18715. * Adds a new size gradient
  18716. * @param gradient defines the gradient to use (between 0 and 1)
  18717. * @param factor defines the size factor to affect to the specified gradient
  18718. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18719. * @returns the current particle system
  18720. */
  18721. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18722. /**
  18723. * Remove a specific size gradient
  18724. * @param gradient defines the gradient to remove
  18725. * @returns the current particle system
  18726. */
  18727. removeSizeGradient(gradient: number): IParticleSystem;
  18728. /**
  18729. * Gets the current list of color gradients.
  18730. * You must use addColorGradient and removeColorGradient to udpate this list
  18731. * @returns the list of color gradients
  18732. */
  18733. getColorGradients(): Nullable<Array<ColorGradient>>;
  18734. /**
  18735. * Gets the current list of size gradients.
  18736. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18737. * @returns the list of size gradients
  18738. */
  18739. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18740. /**
  18741. * Gets the current list of angular speed gradients.
  18742. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18743. * @returns the list of angular speed gradients
  18744. */
  18745. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18746. /**
  18747. * Adds a new angular speed gradient
  18748. * @param gradient defines the gradient to use (between 0 and 1)
  18749. * @param factor defines the angular speed to affect to the specified gradient
  18750. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18751. * @returns the current particle system
  18752. */
  18753. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18754. /**
  18755. * Remove a specific angular speed gradient
  18756. * @param gradient defines the gradient to remove
  18757. * @returns the current particle system
  18758. */
  18759. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18760. /**
  18761. * Gets the current list of velocity gradients.
  18762. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18763. * @returns the list of velocity gradients
  18764. */
  18765. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18766. /**
  18767. * Adds a new velocity gradient
  18768. * @param gradient defines the gradient to use (between 0 and 1)
  18769. * @param factor defines the velocity to affect to the specified gradient
  18770. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18771. * @returns the current particle system
  18772. */
  18773. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18774. /**
  18775. * Remove a specific velocity gradient
  18776. * @param gradient defines the gradient to remove
  18777. * @returns the current particle system
  18778. */
  18779. removeVelocityGradient(gradient: number): IParticleSystem;
  18780. /**
  18781. * Gets the current list of limit velocity gradients.
  18782. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18783. * @returns the list of limit velocity gradients
  18784. */
  18785. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18786. /**
  18787. * Adds a new limit velocity gradient
  18788. * @param gradient defines the gradient to use (between 0 and 1)
  18789. * @param factor defines the limit velocity to affect to the specified gradient
  18790. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18791. * @returns the current particle system
  18792. */
  18793. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18794. /**
  18795. * Remove a specific limit velocity gradient
  18796. * @param gradient defines the gradient to remove
  18797. * @returns the current particle system
  18798. */
  18799. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18800. /**
  18801. * Adds a new drag gradient
  18802. * @param gradient defines the gradient to use (between 0 and 1)
  18803. * @param factor defines the drag to affect to the specified gradient
  18804. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18805. * @returns the current particle system
  18806. */
  18807. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18808. /**
  18809. * Remove a specific drag gradient
  18810. * @param gradient defines the gradient to remove
  18811. * @returns the current particle system
  18812. */
  18813. removeDragGradient(gradient: number): IParticleSystem;
  18814. /**
  18815. * Gets the current list of drag gradients.
  18816. * You must use addDragGradient and removeDragGradient to udpate this list
  18817. * @returns the list of drag gradients
  18818. */
  18819. getDragGradients(): Nullable<Array<FactorGradient>>;
  18820. /**
  18821. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18822. * @param gradient defines the gradient to use (between 0 and 1)
  18823. * @param factor defines the emit rate to affect to the specified gradient
  18824. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18825. * @returns the current particle system
  18826. */
  18827. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18828. /**
  18829. * Remove a specific emit rate gradient
  18830. * @param gradient defines the gradient to remove
  18831. * @returns the current particle system
  18832. */
  18833. removeEmitRateGradient(gradient: number): IParticleSystem;
  18834. /**
  18835. * Gets the current list of emit rate gradients.
  18836. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18837. * @returns the list of emit rate gradients
  18838. */
  18839. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18840. /**
  18841. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18842. * @param gradient defines the gradient to use (between 0 and 1)
  18843. * @param factor defines the start size to affect to the specified gradient
  18844. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18845. * @returns the current particle system
  18846. */
  18847. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18848. /**
  18849. * Remove a specific start size gradient
  18850. * @param gradient defines the gradient to remove
  18851. * @returns the current particle system
  18852. */
  18853. removeStartSizeGradient(gradient: number): IParticleSystem;
  18854. /**
  18855. * Gets the current list of start size gradients.
  18856. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18857. * @returns the list of start size gradients
  18858. */
  18859. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18860. /**
  18861. * Adds a new life time gradient
  18862. * @param gradient defines the gradient to use (between 0 and 1)
  18863. * @param factor defines the life time factor to affect to the specified gradient
  18864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18865. * @returns the current particle system
  18866. */
  18867. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18868. /**
  18869. * Remove a specific life time gradient
  18870. * @param gradient defines the gradient to remove
  18871. * @returns the current particle system
  18872. */
  18873. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18874. /**
  18875. * Gets the current list of life time gradients.
  18876. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18877. * @returns the list of life time gradients
  18878. */
  18879. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18880. /**
  18881. * Gets the current list of color gradients.
  18882. * You must use addColorGradient and removeColorGradient to udpate this list
  18883. * @returns the list of color gradients
  18884. */
  18885. getColorGradients(): Nullable<Array<ColorGradient>>;
  18886. /**
  18887. * Adds a new ramp gradient used to remap particle colors
  18888. * @param gradient defines the gradient to use (between 0 and 1)
  18889. * @param color defines the color to affect to the specified gradient
  18890. * @returns the current particle system
  18891. */
  18892. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18893. /**
  18894. * Gets the current list of ramp gradients.
  18895. * You must use addRampGradient and removeRampGradient to udpate this list
  18896. * @returns the list of ramp gradients
  18897. */
  18898. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18899. /** Gets or sets a boolean indicating that ramp gradients must be used
  18900. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18901. */
  18902. useRampGradients: boolean;
  18903. /**
  18904. * Adds a new color remap gradient
  18905. * @param gradient defines the gradient to use (between 0 and 1)
  18906. * @param min defines the color remap minimal range
  18907. * @param max defines the color remap maximal range
  18908. * @returns the current particle system
  18909. */
  18910. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18911. /**
  18912. * Gets the current list of color remap gradients.
  18913. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18914. * @returns the list of color remap gradients
  18915. */
  18916. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18917. /**
  18918. * Adds a new alpha remap gradient
  18919. * @param gradient defines the gradient to use (between 0 and 1)
  18920. * @param min defines the alpha remap minimal range
  18921. * @param max defines the alpha remap maximal range
  18922. * @returns the current particle system
  18923. */
  18924. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18925. /**
  18926. * Gets the current list of alpha remap gradients.
  18927. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18928. * @returns the list of alpha remap gradients
  18929. */
  18930. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18931. /**
  18932. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18933. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18934. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18935. * @returns the emitter
  18936. */
  18937. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18938. /**
  18939. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18940. * @param radius The radius of the hemisphere to emit from
  18941. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18942. * @returns the emitter
  18943. */
  18944. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18945. /**
  18946. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18947. * @param radius The radius of the sphere to emit from
  18948. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18949. * @returns the emitter
  18950. */
  18951. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18952. /**
  18953. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18954. * @param radius The radius of the sphere to emit from
  18955. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18956. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18957. * @returns the emitter
  18958. */
  18959. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18960. /**
  18961. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18962. * @param radius The radius of the emission cylinder
  18963. * @param height The height of the emission cylinder
  18964. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18965. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18966. * @returns the emitter
  18967. */
  18968. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18969. /**
  18970. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18971. * @param radius The radius of the cylinder to emit from
  18972. * @param height The height of the emission cylinder
  18973. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18974. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18975. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18976. * @returns the emitter
  18977. */
  18978. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18979. /**
  18980. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18981. * @param radius The radius of the cone to emit from
  18982. * @param angle The base angle of the cone
  18983. * @returns the emitter
  18984. */
  18985. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18986. /**
  18987. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18988. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18989. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18990. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18991. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18992. * @returns the emitter
  18993. */
  18994. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18995. /**
  18996. * Get hosting scene
  18997. * @returns the scene
  18998. */
  18999. getScene(): Scene;
  19000. }
  19001. }
  19002. declare module BABYLON {
  19003. /**
  19004. * Creates an instance based on a source mesh.
  19005. */
  19006. export class InstancedMesh extends AbstractMesh {
  19007. private _sourceMesh;
  19008. private _currentLOD;
  19009. /** @hidden */
  19010. _indexInSourceMeshInstanceArray: number;
  19011. constructor(name: string, source: Mesh);
  19012. /**
  19013. * Returns the string "InstancedMesh".
  19014. */
  19015. getClassName(): string;
  19016. /** Gets the list of lights affecting that mesh */
  19017. readonly lightSources: Light[];
  19018. _resyncLightSources(): void;
  19019. _resyncLightSource(light: Light): void;
  19020. _removeLightSource(light: Light, dispose: boolean): void;
  19021. /**
  19022. * If the source mesh receives shadows
  19023. */
  19024. readonly receiveShadows: boolean;
  19025. /**
  19026. * The material of the source mesh
  19027. */
  19028. readonly material: Nullable<Material>;
  19029. /**
  19030. * Visibility of the source mesh
  19031. */
  19032. readonly visibility: number;
  19033. /**
  19034. * Skeleton of the source mesh
  19035. */
  19036. readonly skeleton: Nullable<Skeleton>;
  19037. /**
  19038. * Rendering ground id of the source mesh
  19039. */
  19040. renderingGroupId: number;
  19041. /**
  19042. * Returns the total number of vertices (integer).
  19043. */
  19044. getTotalVertices(): number;
  19045. /**
  19046. * Returns a positive integer : the total number of indices in this mesh geometry.
  19047. * @returns the numner of indices or zero if the mesh has no geometry.
  19048. */
  19049. getTotalIndices(): number;
  19050. /**
  19051. * The source mesh of the instance
  19052. */
  19053. readonly sourceMesh: Mesh;
  19054. /**
  19055. * Is this node ready to be used/rendered
  19056. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19057. * @return {boolean} is it ready
  19058. */
  19059. isReady(completeCheck?: boolean): boolean;
  19060. /**
  19061. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19062. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19063. * @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.
  19064. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19065. */
  19066. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19067. /**
  19068. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19069. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19070. * The `data` are either a numeric array either a Float32Array.
  19071. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19072. * 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).
  19073. * Note that a new underlying VertexBuffer object is created each call.
  19074. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19075. *
  19076. * Possible `kind` values :
  19077. * - VertexBuffer.PositionKind
  19078. * - VertexBuffer.UVKind
  19079. * - VertexBuffer.UV2Kind
  19080. * - VertexBuffer.UV3Kind
  19081. * - VertexBuffer.UV4Kind
  19082. * - VertexBuffer.UV5Kind
  19083. * - VertexBuffer.UV6Kind
  19084. * - VertexBuffer.ColorKind
  19085. * - VertexBuffer.MatricesIndicesKind
  19086. * - VertexBuffer.MatricesIndicesExtraKind
  19087. * - VertexBuffer.MatricesWeightsKind
  19088. * - VertexBuffer.MatricesWeightsExtraKind
  19089. *
  19090. * Returns the Mesh.
  19091. */
  19092. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19093. /**
  19094. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19095. * If the mesh has no geometry, it is simply returned as it is.
  19096. * The `data` are either a numeric array either a Float32Array.
  19097. * No new underlying VertexBuffer object is created.
  19098. * 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.
  19099. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19100. *
  19101. * Possible `kind` values :
  19102. * - VertexBuffer.PositionKind
  19103. * - VertexBuffer.UVKind
  19104. * - VertexBuffer.UV2Kind
  19105. * - VertexBuffer.UV3Kind
  19106. * - VertexBuffer.UV4Kind
  19107. * - VertexBuffer.UV5Kind
  19108. * - VertexBuffer.UV6Kind
  19109. * - VertexBuffer.ColorKind
  19110. * - VertexBuffer.MatricesIndicesKind
  19111. * - VertexBuffer.MatricesIndicesExtraKind
  19112. * - VertexBuffer.MatricesWeightsKind
  19113. * - VertexBuffer.MatricesWeightsExtraKind
  19114. *
  19115. * Returns the Mesh.
  19116. */
  19117. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19118. /**
  19119. * Sets the mesh indices.
  19120. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19121. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19122. * This method creates a new index buffer each call.
  19123. * Returns the Mesh.
  19124. */
  19125. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19126. /**
  19127. * Boolean : True if the mesh owns the requested kind of data.
  19128. */
  19129. isVerticesDataPresent(kind: string): boolean;
  19130. /**
  19131. * Returns an array of indices (IndicesArray).
  19132. */
  19133. getIndices(): Nullable<IndicesArray>;
  19134. readonly _positions: Nullable<Vector3[]>;
  19135. /**
  19136. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19137. * This means the mesh underlying bounding box and sphere are recomputed.
  19138. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19139. * @returns the current mesh
  19140. */
  19141. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19142. /** @hidden */
  19143. _preActivate(): InstancedMesh;
  19144. /** @hidden */
  19145. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19146. /** @hidden */
  19147. _postActivate(): void;
  19148. getWorldMatrix(): Matrix;
  19149. readonly isAnInstance: boolean;
  19150. /**
  19151. * Returns the current associated LOD AbstractMesh.
  19152. */
  19153. getLOD(camera: Camera): AbstractMesh;
  19154. /** @hidden */
  19155. _syncSubMeshes(): InstancedMesh;
  19156. /** @hidden */
  19157. _generatePointsArray(): boolean;
  19158. /**
  19159. * Creates a new InstancedMesh from the current mesh.
  19160. * - name (string) : the cloned mesh name
  19161. * - newParent (optional Node) : the optional Node to parent the clone to.
  19162. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19163. *
  19164. * Returns the clone.
  19165. */
  19166. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19167. /**
  19168. * Disposes the InstancedMesh.
  19169. * Returns nothing.
  19170. */
  19171. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19172. }
  19173. interface Mesh {
  19174. /**
  19175. * Register a custom buffer that will be instanced
  19176. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19177. * @param kind defines the buffer kind
  19178. * @param stride defines the stride in floats
  19179. */
  19180. registerInstancedBuffer(kind: string, stride: number): void;
  19181. /** @hidden */
  19182. _userInstancedBuffersStorage: {
  19183. data: {
  19184. [key: string]: Float32Array;
  19185. };
  19186. sizes: {
  19187. [key: string]: number;
  19188. };
  19189. vertexBuffers: {
  19190. [key: string]: Nullable<VertexBuffer>;
  19191. };
  19192. strides: {
  19193. [key: string]: number;
  19194. };
  19195. };
  19196. }
  19197. interface AbstractMesh {
  19198. /**
  19199. * Object used to store instanced buffers defined by user
  19200. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19201. */
  19202. instancedBuffers: {
  19203. [key: string]: any;
  19204. };
  19205. }
  19206. }
  19207. declare module BABYLON {
  19208. /**
  19209. * Defines the options associated with the creation of a shader material.
  19210. */
  19211. export interface IShaderMaterialOptions {
  19212. /**
  19213. * Does the material work in alpha blend mode
  19214. */
  19215. needAlphaBlending: boolean;
  19216. /**
  19217. * Does the material work in alpha test mode
  19218. */
  19219. needAlphaTesting: boolean;
  19220. /**
  19221. * The list of attribute names used in the shader
  19222. */
  19223. attributes: string[];
  19224. /**
  19225. * The list of unifrom names used in the shader
  19226. */
  19227. uniforms: string[];
  19228. /**
  19229. * The list of UBO names used in the shader
  19230. */
  19231. uniformBuffers: string[];
  19232. /**
  19233. * The list of sampler names used in the shader
  19234. */
  19235. samplers: string[];
  19236. /**
  19237. * The list of defines used in the shader
  19238. */
  19239. defines: string[];
  19240. }
  19241. /**
  19242. * 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.
  19243. *
  19244. * This returned material effects how the mesh will look based on the code in the shaders.
  19245. *
  19246. * @see http://doc.babylonjs.com/how_to/shader_material
  19247. */
  19248. export class ShaderMaterial extends Material {
  19249. private _shaderPath;
  19250. private _options;
  19251. private _textures;
  19252. private _textureArrays;
  19253. private _floats;
  19254. private _ints;
  19255. private _floatsArrays;
  19256. private _colors3;
  19257. private _colors3Arrays;
  19258. private _colors4;
  19259. private _colors4Arrays;
  19260. private _vectors2;
  19261. private _vectors3;
  19262. private _vectors4;
  19263. private _matrices;
  19264. private _matrixArrays;
  19265. private _matrices3x3;
  19266. private _matrices2x2;
  19267. private _vectors2Arrays;
  19268. private _vectors3Arrays;
  19269. private _vectors4Arrays;
  19270. private _cachedWorldViewMatrix;
  19271. private _cachedWorldViewProjectionMatrix;
  19272. private _renderId;
  19273. private _multiview;
  19274. /**
  19275. * Instantiate a new shader material.
  19276. * 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.
  19277. * This returned material effects how the mesh will look based on the code in the shaders.
  19278. * @see http://doc.babylonjs.com/how_to/shader_material
  19279. * @param name Define the name of the material in the scene
  19280. * @param scene Define the scene the material belongs to
  19281. * @param shaderPath Defines the route to the shader code in one of three ways:
  19282. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19283. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19284. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19285. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19286. * @param options Define the options used to create the shader
  19287. */
  19288. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19289. /**
  19290. * Gets the shader path used to define the shader code
  19291. * It can be modified to trigger a new compilation
  19292. */
  19293. /**
  19294. * Sets the shader path used to define the shader code
  19295. * It can be modified to trigger a new compilation
  19296. */
  19297. shaderPath: any;
  19298. /**
  19299. * Gets the options used to compile the shader.
  19300. * They can be modified to trigger a new compilation
  19301. */
  19302. readonly options: IShaderMaterialOptions;
  19303. /**
  19304. * Gets the current class name of the material e.g. "ShaderMaterial"
  19305. * Mainly use in serialization.
  19306. * @returns the class name
  19307. */
  19308. getClassName(): string;
  19309. /**
  19310. * Specifies if the material will require alpha blending
  19311. * @returns a boolean specifying if alpha blending is needed
  19312. */
  19313. needAlphaBlending(): boolean;
  19314. /**
  19315. * Specifies if this material should be rendered in alpha test mode
  19316. * @returns a boolean specifying if an alpha test is needed.
  19317. */
  19318. needAlphaTesting(): boolean;
  19319. private _checkUniform;
  19320. /**
  19321. * Set a texture in the shader.
  19322. * @param name Define the name of the uniform samplers as defined in the shader
  19323. * @param texture Define the texture to bind to this sampler
  19324. * @return the material itself allowing "fluent" like uniform updates
  19325. */
  19326. setTexture(name: string, texture: Texture): ShaderMaterial;
  19327. /**
  19328. * Set a texture array in the shader.
  19329. * @param name Define the name of the uniform sampler array as defined in the shader
  19330. * @param textures Define the list of textures to bind to this sampler
  19331. * @return the material itself allowing "fluent" like uniform updates
  19332. */
  19333. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19334. /**
  19335. * Set a float in the shader.
  19336. * @param name Define the name of the uniform as defined in the shader
  19337. * @param value Define the value to give to the uniform
  19338. * @return the material itself allowing "fluent" like uniform updates
  19339. */
  19340. setFloat(name: string, value: number): ShaderMaterial;
  19341. /**
  19342. * Set a int in the shader.
  19343. * @param name Define the name of the uniform as defined in the shader
  19344. * @param value Define the value to give to the uniform
  19345. * @return the material itself allowing "fluent" like uniform updates
  19346. */
  19347. setInt(name: string, value: number): ShaderMaterial;
  19348. /**
  19349. * Set an array of floats in the shader.
  19350. * @param name Define the name of the uniform as defined in the shader
  19351. * @param value Define the value to give to the uniform
  19352. * @return the material itself allowing "fluent" like uniform updates
  19353. */
  19354. setFloats(name: string, value: number[]): ShaderMaterial;
  19355. /**
  19356. * Set a vec3 in the shader from a Color3.
  19357. * @param name Define the name of the uniform as defined in the shader
  19358. * @param value Define the value to give to the uniform
  19359. * @return the material itself allowing "fluent" like uniform updates
  19360. */
  19361. setColor3(name: string, value: Color3): ShaderMaterial;
  19362. /**
  19363. * Set a vec3 array in the shader from a Color3 array.
  19364. * @param name Define the name of the uniform as defined in the shader
  19365. * @param value Define the value to give to the uniform
  19366. * @return the material itself allowing "fluent" like uniform updates
  19367. */
  19368. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19369. /**
  19370. * Set a vec4 in the shader from a Color4.
  19371. * @param name Define the name of the uniform as defined in the shader
  19372. * @param value Define the value to give to the uniform
  19373. * @return the material itself allowing "fluent" like uniform updates
  19374. */
  19375. setColor4(name: string, value: Color4): ShaderMaterial;
  19376. /**
  19377. * Set a vec4 array in the shader from a Color4 array.
  19378. * @param name Define the name of the uniform as defined in the shader
  19379. * @param value Define the value to give to the uniform
  19380. * @return the material itself allowing "fluent" like uniform updates
  19381. */
  19382. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19383. /**
  19384. * Set a vec2 in the shader from a Vector2.
  19385. * @param name Define the name of the uniform as defined in the shader
  19386. * @param value Define the value to give to the uniform
  19387. * @return the material itself allowing "fluent" like uniform updates
  19388. */
  19389. setVector2(name: string, value: Vector2): ShaderMaterial;
  19390. /**
  19391. * Set a vec3 in the shader from a Vector3.
  19392. * @param name Define the name of the uniform as defined in the shader
  19393. * @param value Define the value to give to the uniform
  19394. * @return the material itself allowing "fluent" like uniform updates
  19395. */
  19396. setVector3(name: string, value: Vector3): ShaderMaterial;
  19397. /**
  19398. * Set a vec4 in the shader from a Vector4.
  19399. * @param name Define the name of the uniform as defined in the shader
  19400. * @param value Define the value to give to the uniform
  19401. * @return the material itself allowing "fluent" like uniform updates
  19402. */
  19403. setVector4(name: string, value: Vector4): ShaderMaterial;
  19404. /**
  19405. * Set a mat4 in the shader from a Matrix.
  19406. * @param name Define the name of the uniform as defined in the shader
  19407. * @param value Define the value to give to the uniform
  19408. * @return the material itself allowing "fluent" like uniform updates
  19409. */
  19410. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19411. /**
  19412. * Set a float32Array in the shader from a matrix array.
  19413. * @param name Define the name of the uniform as defined in the shader
  19414. * @param value Define the value to give to the uniform
  19415. * @return the material itself allowing "fluent" like uniform updates
  19416. */
  19417. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19418. /**
  19419. * Set a mat3 in the shader from a Float32Array.
  19420. * @param name Define the name of the uniform as defined in the shader
  19421. * @param value Define the value to give to the uniform
  19422. * @return the material itself allowing "fluent" like uniform updates
  19423. */
  19424. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19425. /**
  19426. * Set a mat2 in the shader from a Float32Array.
  19427. * @param name Define the name of the uniform as defined in the shader
  19428. * @param value Define the value to give to the uniform
  19429. * @return the material itself allowing "fluent" like uniform updates
  19430. */
  19431. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19432. /**
  19433. * Set a vec2 array in the shader from a number array.
  19434. * @param name Define the name of the uniform as defined in the shader
  19435. * @param value Define the value to give to the uniform
  19436. * @return the material itself allowing "fluent" like uniform updates
  19437. */
  19438. setArray2(name: string, value: number[]): ShaderMaterial;
  19439. /**
  19440. * Set a vec3 array in the shader from a number array.
  19441. * @param name Define the name of the uniform as defined in the shader
  19442. * @param value Define the value to give to the uniform
  19443. * @return the material itself allowing "fluent" like uniform updates
  19444. */
  19445. setArray3(name: string, value: number[]): ShaderMaterial;
  19446. /**
  19447. * Set a vec4 array in the shader from a number array.
  19448. * @param name Define the name of the uniform as defined in the shader
  19449. * @param value Define the value to give to the uniform
  19450. * @return the material itself allowing "fluent" like uniform updates
  19451. */
  19452. setArray4(name: string, value: number[]): ShaderMaterial;
  19453. private _checkCache;
  19454. /**
  19455. * Specifies that the submesh is ready to be used
  19456. * @param mesh defines the mesh to check
  19457. * @param subMesh defines which submesh to check
  19458. * @param useInstances specifies that instances should be used
  19459. * @returns a boolean indicating that the submesh is ready or not
  19460. */
  19461. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19462. /**
  19463. * Checks if the material is ready to render the requested mesh
  19464. * @param mesh Define the mesh to render
  19465. * @param useInstances Define whether or not the material is used with instances
  19466. * @returns true if ready, otherwise false
  19467. */
  19468. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19469. /**
  19470. * Binds the world matrix to the material
  19471. * @param world defines the world transformation matrix
  19472. */
  19473. bindOnlyWorldMatrix(world: Matrix): void;
  19474. /**
  19475. * Binds the material to the mesh
  19476. * @param world defines the world transformation matrix
  19477. * @param mesh defines the mesh to bind the material to
  19478. */
  19479. bind(world: Matrix, mesh?: Mesh): void;
  19480. /**
  19481. * Gets the active textures from the material
  19482. * @returns an array of textures
  19483. */
  19484. getActiveTextures(): BaseTexture[];
  19485. /**
  19486. * Specifies if the material uses a texture
  19487. * @param texture defines the texture to check against the material
  19488. * @returns a boolean specifying if the material uses the texture
  19489. */
  19490. hasTexture(texture: BaseTexture): boolean;
  19491. /**
  19492. * Makes a duplicate of the material, and gives it a new name
  19493. * @param name defines the new name for the duplicated material
  19494. * @returns the cloned material
  19495. */
  19496. clone(name: string): ShaderMaterial;
  19497. /**
  19498. * Disposes the material
  19499. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19500. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19501. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19502. */
  19503. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19504. /**
  19505. * Serializes this material in a JSON representation
  19506. * @returns the serialized material object
  19507. */
  19508. serialize(): any;
  19509. /**
  19510. * Creates a shader material from parsed shader material data
  19511. * @param source defines the JSON represnetation of the material
  19512. * @param scene defines the hosting scene
  19513. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19514. * @returns a new material
  19515. */
  19516. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19517. }
  19518. }
  19519. declare module BABYLON {
  19520. /** @hidden */
  19521. export var colorPixelShader: {
  19522. name: string;
  19523. shader: string;
  19524. };
  19525. }
  19526. declare module BABYLON {
  19527. /** @hidden */
  19528. export var colorVertexShader: {
  19529. name: string;
  19530. shader: string;
  19531. };
  19532. }
  19533. declare module BABYLON {
  19534. /**
  19535. * Line mesh
  19536. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19537. */
  19538. export class LinesMesh extends Mesh {
  19539. /**
  19540. * If vertex color should be applied to the mesh
  19541. */
  19542. readonly useVertexColor?: boolean | undefined;
  19543. /**
  19544. * If vertex alpha should be applied to the mesh
  19545. */
  19546. readonly useVertexAlpha?: boolean | undefined;
  19547. /**
  19548. * Color of the line (Default: White)
  19549. */
  19550. color: Color3;
  19551. /**
  19552. * Alpha of the line (Default: 1)
  19553. */
  19554. alpha: number;
  19555. /**
  19556. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19557. * This margin is expressed in world space coordinates, so its value may vary.
  19558. * Default value is 0.1
  19559. */
  19560. intersectionThreshold: number;
  19561. private _colorShader;
  19562. private color4;
  19563. /**
  19564. * Creates a new LinesMesh
  19565. * @param name defines the name
  19566. * @param scene defines the hosting scene
  19567. * @param parent defines the parent mesh if any
  19568. * @param source defines the optional source LinesMesh used to clone data from
  19569. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19570. * When false, achieved by calling a clone(), also passing False.
  19571. * This will make creation of children, recursive.
  19572. * @param useVertexColor defines if this LinesMesh supports vertex color
  19573. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19574. */
  19575. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19576. /**
  19577. * If vertex color should be applied to the mesh
  19578. */
  19579. useVertexColor?: boolean | undefined,
  19580. /**
  19581. * If vertex alpha should be applied to the mesh
  19582. */
  19583. useVertexAlpha?: boolean | undefined);
  19584. private _addClipPlaneDefine;
  19585. private _removeClipPlaneDefine;
  19586. isReady(): boolean;
  19587. /**
  19588. * Returns the string "LineMesh"
  19589. */
  19590. getClassName(): string;
  19591. /**
  19592. * @hidden
  19593. */
  19594. /**
  19595. * @hidden
  19596. */
  19597. material: Material;
  19598. /**
  19599. * @hidden
  19600. */
  19601. readonly checkCollisions: boolean;
  19602. /** @hidden */
  19603. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19604. /** @hidden */
  19605. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19606. /**
  19607. * Disposes of the line mesh
  19608. * @param doNotRecurse If children should be disposed
  19609. */
  19610. dispose(doNotRecurse?: boolean): void;
  19611. /**
  19612. * Returns a new LineMesh object cloned from the current one.
  19613. */
  19614. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19615. /**
  19616. * Creates a new InstancedLinesMesh object from the mesh model.
  19617. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19618. * @param name defines the name of the new instance
  19619. * @returns a new InstancedLinesMesh
  19620. */
  19621. createInstance(name: string): InstancedLinesMesh;
  19622. }
  19623. /**
  19624. * Creates an instance based on a source LinesMesh
  19625. */
  19626. export class InstancedLinesMesh extends InstancedMesh {
  19627. /**
  19628. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19629. * This margin is expressed in world space coordinates, so its value may vary.
  19630. * Initilized with the intersectionThreshold value of the source LinesMesh
  19631. */
  19632. intersectionThreshold: number;
  19633. constructor(name: string, source: LinesMesh);
  19634. /**
  19635. * Returns the string "InstancedLinesMesh".
  19636. */
  19637. getClassName(): string;
  19638. }
  19639. }
  19640. declare module BABYLON {
  19641. /** @hidden */
  19642. export var linePixelShader: {
  19643. name: string;
  19644. shader: string;
  19645. };
  19646. }
  19647. declare module BABYLON {
  19648. /** @hidden */
  19649. export var lineVertexShader: {
  19650. name: string;
  19651. shader: string;
  19652. };
  19653. }
  19654. declare module BABYLON {
  19655. interface AbstractMesh {
  19656. /**
  19657. * Gets the edgesRenderer associated with the mesh
  19658. */
  19659. edgesRenderer: Nullable<EdgesRenderer>;
  19660. }
  19661. interface LinesMesh {
  19662. /**
  19663. * Enables the edge rendering mode on the mesh.
  19664. * This mode makes the mesh edges visible
  19665. * @param epsilon defines the maximal distance between two angles to detect a face
  19666. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19667. * @returns the currentAbstractMesh
  19668. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19669. */
  19670. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19671. }
  19672. interface InstancedLinesMesh {
  19673. /**
  19674. * Enables the edge rendering mode on the mesh.
  19675. * This mode makes the mesh edges visible
  19676. * @param epsilon defines the maximal distance between two angles to detect a face
  19677. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19678. * @returns the current InstancedLinesMesh
  19679. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19680. */
  19681. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19682. }
  19683. /**
  19684. * Defines the minimum contract an Edges renderer should follow.
  19685. */
  19686. export interface IEdgesRenderer extends IDisposable {
  19687. /**
  19688. * Gets or sets a boolean indicating if the edgesRenderer is active
  19689. */
  19690. isEnabled: boolean;
  19691. /**
  19692. * Renders the edges of the attached mesh,
  19693. */
  19694. render(): void;
  19695. /**
  19696. * Checks wether or not the edges renderer is ready to render.
  19697. * @return true if ready, otherwise false.
  19698. */
  19699. isReady(): boolean;
  19700. }
  19701. /**
  19702. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19703. */
  19704. export class EdgesRenderer implements IEdgesRenderer {
  19705. /**
  19706. * Define the size of the edges with an orthographic camera
  19707. */
  19708. edgesWidthScalerForOrthographic: number;
  19709. /**
  19710. * Define the size of the edges with a perspective camera
  19711. */
  19712. edgesWidthScalerForPerspective: number;
  19713. protected _source: AbstractMesh;
  19714. protected _linesPositions: number[];
  19715. protected _linesNormals: number[];
  19716. protected _linesIndices: number[];
  19717. protected _epsilon: number;
  19718. protected _indicesCount: number;
  19719. protected _lineShader: ShaderMaterial;
  19720. protected _ib: DataBuffer;
  19721. protected _buffers: {
  19722. [key: string]: Nullable<VertexBuffer>;
  19723. };
  19724. protected _checkVerticesInsteadOfIndices: boolean;
  19725. private _meshRebuildObserver;
  19726. private _meshDisposeObserver;
  19727. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19728. isEnabled: boolean;
  19729. /**
  19730. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19731. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19732. * @param source Mesh used to create edges
  19733. * @param epsilon sum of angles in adjacency to check for edge
  19734. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19735. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19736. */
  19737. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19738. protected _prepareRessources(): void;
  19739. /** @hidden */
  19740. _rebuild(): void;
  19741. /**
  19742. * Releases the required resources for the edges renderer
  19743. */
  19744. dispose(): void;
  19745. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19746. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19747. /**
  19748. * Checks if the pair of p0 and p1 is en edge
  19749. * @param faceIndex
  19750. * @param edge
  19751. * @param faceNormals
  19752. * @param p0
  19753. * @param p1
  19754. * @private
  19755. */
  19756. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19757. /**
  19758. * push line into the position, normal and index buffer
  19759. * @protected
  19760. */
  19761. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19762. /**
  19763. * Generates lines edges from adjacencjes
  19764. * @private
  19765. */
  19766. _generateEdgesLines(): void;
  19767. /**
  19768. * Checks wether or not the edges renderer is ready to render.
  19769. * @return true if ready, otherwise false.
  19770. */
  19771. isReady(): boolean;
  19772. /**
  19773. * Renders the edges of the attached mesh,
  19774. */
  19775. render(): void;
  19776. }
  19777. /**
  19778. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19779. */
  19780. export class LineEdgesRenderer extends EdgesRenderer {
  19781. /**
  19782. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19783. * @param source LineMesh used to generate edges
  19784. * @param epsilon not important (specified angle for edge detection)
  19785. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19786. */
  19787. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19788. /**
  19789. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19790. */
  19791. _generateEdgesLines(): void;
  19792. }
  19793. }
  19794. declare module BABYLON {
  19795. /**
  19796. * This represents the object necessary to create a rendering group.
  19797. * This is exclusively used and created by the rendering manager.
  19798. * To modify the behavior, you use the available helpers in your scene or meshes.
  19799. * @hidden
  19800. */
  19801. export class RenderingGroup {
  19802. index: number;
  19803. private static _zeroVector;
  19804. private _scene;
  19805. private _opaqueSubMeshes;
  19806. private _transparentSubMeshes;
  19807. private _alphaTestSubMeshes;
  19808. private _depthOnlySubMeshes;
  19809. private _particleSystems;
  19810. private _spriteManagers;
  19811. private _opaqueSortCompareFn;
  19812. private _alphaTestSortCompareFn;
  19813. private _transparentSortCompareFn;
  19814. private _renderOpaque;
  19815. private _renderAlphaTest;
  19816. private _renderTransparent;
  19817. /** @hidden */
  19818. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19819. onBeforeTransparentRendering: () => void;
  19820. /**
  19821. * Set the opaque sort comparison function.
  19822. * If null the sub meshes will be render in the order they were created
  19823. */
  19824. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19825. /**
  19826. * Set the alpha test sort comparison function.
  19827. * If null the sub meshes will be render in the order they were created
  19828. */
  19829. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19830. /**
  19831. * Set the transparent sort comparison function.
  19832. * If null the sub meshes will be render in the order they were created
  19833. */
  19834. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19835. /**
  19836. * Creates a new rendering group.
  19837. * @param index The rendering group index
  19838. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19839. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19840. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19841. */
  19842. 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>);
  19843. /**
  19844. * Render all the sub meshes contained in the group.
  19845. * @param customRenderFunction Used to override the default render behaviour of the group.
  19846. * @returns true if rendered some submeshes.
  19847. */
  19848. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19849. /**
  19850. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19851. * @param subMeshes The submeshes to render
  19852. */
  19853. private renderOpaqueSorted;
  19854. /**
  19855. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19856. * @param subMeshes The submeshes to render
  19857. */
  19858. private renderAlphaTestSorted;
  19859. /**
  19860. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19861. * @param subMeshes The submeshes to render
  19862. */
  19863. private renderTransparentSorted;
  19864. /**
  19865. * Renders the submeshes in a specified order.
  19866. * @param subMeshes The submeshes to sort before render
  19867. * @param sortCompareFn The comparison function use to sort
  19868. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19869. * @param transparent Specifies to activate blending if true
  19870. */
  19871. private static renderSorted;
  19872. /**
  19873. * Renders the submeshes in the order they were dispatched (no sort applied).
  19874. * @param subMeshes The submeshes to render
  19875. */
  19876. private static renderUnsorted;
  19877. /**
  19878. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19879. * are rendered back to front if in the same alpha index.
  19880. *
  19881. * @param a The first submesh
  19882. * @param b The second submesh
  19883. * @returns The result of the comparison
  19884. */
  19885. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19886. /**
  19887. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19888. * are rendered back to front.
  19889. *
  19890. * @param a The first submesh
  19891. * @param b The second submesh
  19892. * @returns The result of the comparison
  19893. */
  19894. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19895. /**
  19896. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19897. * are rendered front to back (prevent overdraw).
  19898. *
  19899. * @param a The first submesh
  19900. * @param b The second submesh
  19901. * @returns The result of the comparison
  19902. */
  19903. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19904. /**
  19905. * Resets the different lists of submeshes to prepare a new frame.
  19906. */
  19907. prepare(): void;
  19908. dispose(): void;
  19909. /**
  19910. * Inserts the submesh in its correct queue depending on its material.
  19911. * @param subMesh The submesh to dispatch
  19912. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19913. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19914. */
  19915. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19916. dispatchSprites(spriteManager: ISpriteManager): void;
  19917. dispatchParticles(particleSystem: IParticleSystem): void;
  19918. private _renderParticles;
  19919. private _renderSprites;
  19920. }
  19921. }
  19922. declare module BABYLON {
  19923. /**
  19924. * Interface describing the different options available in the rendering manager
  19925. * regarding Auto Clear between groups.
  19926. */
  19927. export interface IRenderingManagerAutoClearSetup {
  19928. /**
  19929. * Defines whether or not autoclear is enable.
  19930. */
  19931. autoClear: boolean;
  19932. /**
  19933. * Defines whether or not to autoclear the depth buffer.
  19934. */
  19935. depth: boolean;
  19936. /**
  19937. * Defines whether or not to autoclear the stencil buffer.
  19938. */
  19939. stencil: boolean;
  19940. }
  19941. /**
  19942. * This class is used by the onRenderingGroupObservable
  19943. */
  19944. export class RenderingGroupInfo {
  19945. /**
  19946. * The Scene that being rendered
  19947. */
  19948. scene: Scene;
  19949. /**
  19950. * The camera currently used for the rendering pass
  19951. */
  19952. camera: Nullable<Camera>;
  19953. /**
  19954. * The ID of the renderingGroup being processed
  19955. */
  19956. renderingGroupId: number;
  19957. }
  19958. /**
  19959. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19960. * It is enable to manage the different groups as well as the different necessary sort functions.
  19961. * This should not be used directly aside of the few static configurations
  19962. */
  19963. export class RenderingManager {
  19964. /**
  19965. * The max id used for rendering groups (not included)
  19966. */
  19967. static MAX_RENDERINGGROUPS: number;
  19968. /**
  19969. * The min id used for rendering groups (included)
  19970. */
  19971. static MIN_RENDERINGGROUPS: number;
  19972. /**
  19973. * Used to globally prevent autoclearing scenes.
  19974. */
  19975. static AUTOCLEAR: boolean;
  19976. /**
  19977. * @hidden
  19978. */
  19979. _useSceneAutoClearSetup: boolean;
  19980. private _scene;
  19981. private _renderingGroups;
  19982. private _depthStencilBufferAlreadyCleaned;
  19983. private _autoClearDepthStencil;
  19984. private _customOpaqueSortCompareFn;
  19985. private _customAlphaTestSortCompareFn;
  19986. private _customTransparentSortCompareFn;
  19987. private _renderingGroupInfo;
  19988. /**
  19989. * Instantiates a new rendering group for a particular scene
  19990. * @param scene Defines the scene the groups belongs to
  19991. */
  19992. constructor(scene: Scene);
  19993. private _clearDepthStencilBuffer;
  19994. /**
  19995. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19996. * @hidden
  19997. */
  19998. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19999. /**
  20000. * Resets the different information of the group to prepare a new frame
  20001. * @hidden
  20002. */
  20003. reset(): void;
  20004. /**
  20005. * Dispose and release the group and its associated resources.
  20006. * @hidden
  20007. */
  20008. dispose(): void;
  20009. /**
  20010. * Clear the info related to rendering groups preventing retention points during dispose.
  20011. */
  20012. freeRenderingGroups(): void;
  20013. private _prepareRenderingGroup;
  20014. /**
  20015. * Add a sprite manager to the rendering manager in order to render it this frame.
  20016. * @param spriteManager Define the sprite manager to render
  20017. */
  20018. dispatchSprites(spriteManager: ISpriteManager): void;
  20019. /**
  20020. * Add a particle system to the rendering manager in order to render it this frame.
  20021. * @param particleSystem Define the particle system to render
  20022. */
  20023. dispatchParticles(particleSystem: IParticleSystem): void;
  20024. /**
  20025. * Add a submesh to the manager in order to render it this frame
  20026. * @param subMesh The submesh to dispatch
  20027. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20028. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20029. */
  20030. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20031. /**
  20032. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20033. * This allowed control for front to back rendering or reversly depending of the special needs.
  20034. *
  20035. * @param renderingGroupId The rendering group id corresponding to its index
  20036. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20037. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20038. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20039. */
  20040. 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;
  20041. /**
  20042. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20043. *
  20044. * @param renderingGroupId The rendering group id corresponding to its index
  20045. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20046. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20047. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20048. */
  20049. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20050. /**
  20051. * Gets the current auto clear configuration for one rendering group of the rendering
  20052. * manager.
  20053. * @param index the rendering group index to get the information for
  20054. * @returns The auto clear setup for the requested rendering group
  20055. */
  20056. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20057. }
  20058. }
  20059. declare module BABYLON {
  20060. /**
  20061. * This Helps creating a texture that will be created from a camera in your scene.
  20062. * It is basically a dynamic texture that could be used to create special effects for instance.
  20063. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20064. */
  20065. export class RenderTargetTexture extends Texture {
  20066. isCube: boolean;
  20067. /**
  20068. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20069. */
  20070. static readonly REFRESHRATE_RENDER_ONCE: number;
  20071. /**
  20072. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20073. */
  20074. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20075. /**
  20076. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20077. * the central point of your effect and can save a lot of performances.
  20078. */
  20079. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20080. /**
  20081. * Use this predicate to dynamically define the list of mesh you want to render.
  20082. * If set, the renderList property will be overwritten.
  20083. */
  20084. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20085. private _renderList;
  20086. /**
  20087. * Use this list to define the list of mesh you want to render.
  20088. */
  20089. renderList: Nullable<Array<AbstractMesh>>;
  20090. private _hookArray;
  20091. /**
  20092. * Define if particles should be rendered in your texture.
  20093. */
  20094. renderParticles: boolean;
  20095. /**
  20096. * Define if sprites should be rendered in your texture.
  20097. */
  20098. renderSprites: boolean;
  20099. /**
  20100. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20101. */
  20102. coordinatesMode: number;
  20103. /**
  20104. * Define the camera used to render the texture.
  20105. */
  20106. activeCamera: Nullable<Camera>;
  20107. /**
  20108. * Override the render function of the texture with your own one.
  20109. */
  20110. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20111. /**
  20112. * Define if camera post processes should be use while rendering the texture.
  20113. */
  20114. useCameraPostProcesses: boolean;
  20115. /**
  20116. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20117. */
  20118. ignoreCameraViewport: boolean;
  20119. private _postProcessManager;
  20120. private _postProcesses;
  20121. private _resizeObserver;
  20122. /**
  20123. * An event triggered when the texture is unbind.
  20124. */
  20125. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20126. /**
  20127. * An event triggered when the texture is unbind.
  20128. */
  20129. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20130. private _onAfterUnbindObserver;
  20131. /**
  20132. * Set a after unbind callback in the texture.
  20133. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20134. */
  20135. onAfterUnbind: () => void;
  20136. /**
  20137. * An event triggered before rendering the texture
  20138. */
  20139. onBeforeRenderObservable: Observable<number>;
  20140. private _onBeforeRenderObserver;
  20141. /**
  20142. * Set a before render callback in the texture.
  20143. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20144. */
  20145. onBeforeRender: (faceIndex: number) => void;
  20146. /**
  20147. * An event triggered after rendering the texture
  20148. */
  20149. onAfterRenderObservable: Observable<number>;
  20150. private _onAfterRenderObserver;
  20151. /**
  20152. * Set a after render callback in the texture.
  20153. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20154. */
  20155. onAfterRender: (faceIndex: number) => void;
  20156. /**
  20157. * An event triggered after the texture clear
  20158. */
  20159. onClearObservable: Observable<Engine>;
  20160. private _onClearObserver;
  20161. /**
  20162. * Set a clear callback in the texture.
  20163. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20164. */
  20165. onClear: (Engine: Engine) => void;
  20166. /**
  20167. * An event triggered when the texture is resized.
  20168. */
  20169. onResizeObservable: Observable<RenderTargetTexture>;
  20170. /**
  20171. * Define the clear color of the Render Target if it should be different from the scene.
  20172. */
  20173. clearColor: Color4;
  20174. protected _size: number | {
  20175. width: number;
  20176. height: number;
  20177. };
  20178. protected _initialSizeParameter: number | {
  20179. width: number;
  20180. height: number;
  20181. } | {
  20182. ratio: number;
  20183. };
  20184. protected _sizeRatio: Nullable<number>;
  20185. /** @hidden */
  20186. _generateMipMaps: boolean;
  20187. protected _renderingManager: RenderingManager;
  20188. /** @hidden */
  20189. _waitingRenderList: string[];
  20190. protected _doNotChangeAspectRatio: boolean;
  20191. protected _currentRefreshId: number;
  20192. protected _refreshRate: number;
  20193. protected _textureMatrix: Matrix;
  20194. protected _samples: number;
  20195. protected _renderTargetOptions: RenderTargetCreationOptions;
  20196. /**
  20197. * Gets render target creation options that were used.
  20198. */
  20199. readonly renderTargetOptions: RenderTargetCreationOptions;
  20200. protected _engine: Engine;
  20201. protected _onRatioRescale(): void;
  20202. /**
  20203. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20204. * It must define where the camera used to render the texture is set
  20205. */
  20206. boundingBoxPosition: Vector3;
  20207. private _boundingBoxSize;
  20208. /**
  20209. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20210. * When defined, the cubemap will switch to local mode
  20211. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20212. * @example https://www.babylonjs-playground.com/#RNASML
  20213. */
  20214. boundingBoxSize: Vector3;
  20215. /**
  20216. * In case the RTT has been created with a depth texture, get the associated
  20217. * depth texture.
  20218. * Otherwise, return null.
  20219. */
  20220. depthStencilTexture: Nullable<InternalTexture>;
  20221. /**
  20222. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20223. * or used a shadow, depth texture...
  20224. * @param name The friendly name of the texture
  20225. * @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)
  20226. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20227. * @param generateMipMaps True if mip maps need to be generated after render.
  20228. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20229. * @param type The type of the buffer in the RTT (int, half float, float...)
  20230. * @param isCube True if a cube texture needs to be created
  20231. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20232. * @param generateDepthBuffer True to generate a depth buffer
  20233. * @param generateStencilBuffer True to generate a stencil buffer
  20234. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20235. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20236. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20237. */
  20238. constructor(name: string, size: number | {
  20239. width: number;
  20240. height: number;
  20241. } | {
  20242. ratio: number;
  20243. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20244. /**
  20245. * Creates a depth stencil texture.
  20246. * This is only available in WebGL 2 or with the depth texture extension available.
  20247. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20248. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20249. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20250. */
  20251. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20252. private _processSizeParameter;
  20253. /**
  20254. * Define the number of samples to use in case of MSAA.
  20255. * It defaults to one meaning no MSAA has been enabled.
  20256. */
  20257. samples: number;
  20258. /**
  20259. * Resets the refresh counter of the texture and start bak from scratch.
  20260. * Could be useful to regenerate the texture if it is setup to render only once.
  20261. */
  20262. resetRefreshCounter(): void;
  20263. /**
  20264. * Define the refresh rate of the texture or the rendering frequency.
  20265. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20266. */
  20267. refreshRate: number;
  20268. /**
  20269. * Adds a post process to the render target rendering passes.
  20270. * @param postProcess define the post process to add
  20271. */
  20272. addPostProcess(postProcess: PostProcess): void;
  20273. /**
  20274. * Clear all the post processes attached to the render target
  20275. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20276. */
  20277. clearPostProcesses(dispose?: boolean): void;
  20278. /**
  20279. * Remove one of the post process from the list of attached post processes to the texture
  20280. * @param postProcess define the post process to remove from the list
  20281. */
  20282. removePostProcess(postProcess: PostProcess): void;
  20283. /** @hidden */
  20284. _shouldRender(): boolean;
  20285. /**
  20286. * Gets the actual render size of the texture.
  20287. * @returns the width of the render size
  20288. */
  20289. getRenderSize(): number;
  20290. /**
  20291. * Gets the actual render width of the texture.
  20292. * @returns the width of the render size
  20293. */
  20294. getRenderWidth(): number;
  20295. /**
  20296. * Gets the actual render height of the texture.
  20297. * @returns the height of the render size
  20298. */
  20299. getRenderHeight(): number;
  20300. /**
  20301. * Get if the texture can be rescaled or not.
  20302. */
  20303. readonly canRescale: boolean;
  20304. /**
  20305. * Resize the texture using a ratio.
  20306. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20307. */
  20308. scale(ratio: number): void;
  20309. /**
  20310. * Get the texture reflection matrix used to rotate/transform the reflection.
  20311. * @returns the reflection matrix
  20312. */
  20313. getReflectionTextureMatrix(): Matrix;
  20314. /**
  20315. * Resize the texture to a new desired size.
  20316. * Be carrefull as it will recreate all the data in the new texture.
  20317. * @param size Define the new size. It can be:
  20318. * - a number for squared texture,
  20319. * - an object containing { width: number, height: number }
  20320. * - or an object containing a ratio { ratio: number }
  20321. */
  20322. resize(size: number | {
  20323. width: number;
  20324. height: number;
  20325. } | {
  20326. ratio: number;
  20327. }): void;
  20328. /**
  20329. * Renders all the objects from the render list into the texture.
  20330. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20331. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20332. */
  20333. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20334. private _bestReflectionRenderTargetDimension;
  20335. /**
  20336. * @hidden
  20337. * @param faceIndex face index to bind to if this is a cubetexture
  20338. */
  20339. _bindFrameBuffer(faceIndex?: number): void;
  20340. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20341. private renderToTarget;
  20342. /**
  20343. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20344. * This allowed control for front to back rendering or reversly depending of the special needs.
  20345. *
  20346. * @param renderingGroupId The rendering group id corresponding to its index
  20347. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20348. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20349. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20350. */
  20351. 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;
  20352. /**
  20353. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20354. *
  20355. * @param renderingGroupId The rendering group id corresponding to its index
  20356. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20357. */
  20358. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20359. /**
  20360. * Clones the texture.
  20361. * @returns the cloned texture
  20362. */
  20363. clone(): RenderTargetTexture;
  20364. /**
  20365. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20366. * @returns The JSON representation of the texture
  20367. */
  20368. serialize(): any;
  20369. /**
  20370. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20371. */
  20372. disposeFramebufferObjects(): void;
  20373. /**
  20374. * Dispose the texture and release its associated resources.
  20375. */
  20376. dispose(): void;
  20377. /** @hidden */
  20378. _rebuild(): void;
  20379. /**
  20380. * Clear the info related to rendering groups preventing retention point in material dispose.
  20381. */
  20382. freeRenderingGroups(): void;
  20383. /**
  20384. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20385. * @returns the view count
  20386. */
  20387. getViewCount(): number;
  20388. }
  20389. }
  20390. declare module BABYLON {
  20391. /**
  20392. * Options for compiling materials.
  20393. */
  20394. export interface IMaterialCompilationOptions {
  20395. /**
  20396. * Defines whether clip planes are enabled.
  20397. */
  20398. clipPlane: boolean;
  20399. /**
  20400. * Defines whether instances are enabled.
  20401. */
  20402. useInstances: boolean;
  20403. }
  20404. /**
  20405. * Base class for the main features of a material in Babylon.js
  20406. */
  20407. export class Material implements IAnimatable {
  20408. /**
  20409. * Returns the triangle fill mode
  20410. */
  20411. static readonly TriangleFillMode: number;
  20412. /**
  20413. * Returns the wireframe mode
  20414. */
  20415. static readonly WireFrameFillMode: number;
  20416. /**
  20417. * Returns the point fill mode
  20418. */
  20419. static readonly PointFillMode: number;
  20420. /**
  20421. * Returns the point list draw mode
  20422. */
  20423. static readonly PointListDrawMode: number;
  20424. /**
  20425. * Returns the line list draw mode
  20426. */
  20427. static readonly LineListDrawMode: number;
  20428. /**
  20429. * Returns the line loop draw mode
  20430. */
  20431. static readonly LineLoopDrawMode: number;
  20432. /**
  20433. * Returns the line strip draw mode
  20434. */
  20435. static readonly LineStripDrawMode: number;
  20436. /**
  20437. * Returns the triangle strip draw mode
  20438. */
  20439. static readonly TriangleStripDrawMode: number;
  20440. /**
  20441. * Returns the triangle fan draw mode
  20442. */
  20443. static readonly TriangleFanDrawMode: number;
  20444. /**
  20445. * Stores the clock-wise side orientation
  20446. */
  20447. static readonly ClockWiseSideOrientation: number;
  20448. /**
  20449. * Stores the counter clock-wise side orientation
  20450. */
  20451. static readonly CounterClockWiseSideOrientation: number;
  20452. /**
  20453. * The dirty texture flag value
  20454. */
  20455. static readonly TextureDirtyFlag: number;
  20456. /**
  20457. * The dirty light flag value
  20458. */
  20459. static readonly LightDirtyFlag: number;
  20460. /**
  20461. * The dirty fresnel flag value
  20462. */
  20463. static readonly FresnelDirtyFlag: number;
  20464. /**
  20465. * The dirty attribute flag value
  20466. */
  20467. static readonly AttributesDirtyFlag: number;
  20468. /**
  20469. * The dirty misc flag value
  20470. */
  20471. static readonly MiscDirtyFlag: number;
  20472. /**
  20473. * The all dirty flag value
  20474. */
  20475. static readonly AllDirtyFlag: number;
  20476. /**
  20477. * The ID of the material
  20478. */
  20479. id: string;
  20480. /**
  20481. * Gets or sets the unique id of the material
  20482. */
  20483. uniqueId: number;
  20484. /**
  20485. * The name of the material
  20486. */
  20487. name: string;
  20488. /**
  20489. * Gets or sets user defined metadata
  20490. */
  20491. metadata: any;
  20492. /**
  20493. * For internal use only. Please do not use.
  20494. */
  20495. reservedDataStore: any;
  20496. /**
  20497. * Specifies if the ready state should be checked on each call
  20498. */
  20499. checkReadyOnEveryCall: boolean;
  20500. /**
  20501. * Specifies if the ready state should be checked once
  20502. */
  20503. checkReadyOnlyOnce: boolean;
  20504. /**
  20505. * The state of the material
  20506. */
  20507. state: string;
  20508. /**
  20509. * The alpha value of the material
  20510. */
  20511. protected _alpha: number;
  20512. /**
  20513. * List of inspectable custom properties (used by the Inspector)
  20514. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20515. */
  20516. inspectableCustomProperties: IInspectable[];
  20517. /**
  20518. * Sets the alpha value of the material
  20519. */
  20520. /**
  20521. * Gets the alpha value of the material
  20522. */
  20523. alpha: number;
  20524. /**
  20525. * Specifies if back face culling is enabled
  20526. */
  20527. protected _backFaceCulling: boolean;
  20528. /**
  20529. * Sets the back-face culling state
  20530. */
  20531. /**
  20532. * Gets the back-face culling state
  20533. */
  20534. backFaceCulling: boolean;
  20535. /**
  20536. * Stores the value for side orientation
  20537. */
  20538. sideOrientation: number;
  20539. /**
  20540. * Callback triggered when the material is compiled
  20541. */
  20542. onCompiled: Nullable<(effect: Effect) => void>;
  20543. /**
  20544. * Callback triggered when an error occurs
  20545. */
  20546. onError: Nullable<(effect: Effect, errors: string) => void>;
  20547. /**
  20548. * Callback triggered to get the render target textures
  20549. */
  20550. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20551. /**
  20552. * Gets a boolean indicating that current material needs to register RTT
  20553. */
  20554. readonly hasRenderTargetTextures: boolean;
  20555. /**
  20556. * Specifies if the material should be serialized
  20557. */
  20558. doNotSerialize: boolean;
  20559. /**
  20560. * @hidden
  20561. */
  20562. _storeEffectOnSubMeshes: boolean;
  20563. /**
  20564. * Stores the animations for the material
  20565. */
  20566. animations: Nullable<Array<Animation>>;
  20567. /**
  20568. * An event triggered when the material is disposed
  20569. */
  20570. onDisposeObservable: Observable<Material>;
  20571. /**
  20572. * An observer which watches for dispose events
  20573. */
  20574. private _onDisposeObserver;
  20575. private _onUnBindObservable;
  20576. /**
  20577. * Called during a dispose event
  20578. */
  20579. onDispose: () => void;
  20580. private _onBindObservable;
  20581. /**
  20582. * An event triggered when the material is bound
  20583. */
  20584. readonly onBindObservable: Observable<AbstractMesh>;
  20585. /**
  20586. * An observer which watches for bind events
  20587. */
  20588. private _onBindObserver;
  20589. /**
  20590. * Called during a bind event
  20591. */
  20592. onBind: (Mesh: AbstractMesh) => void;
  20593. /**
  20594. * An event triggered when the material is unbound
  20595. */
  20596. readonly onUnBindObservable: Observable<Material>;
  20597. /**
  20598. * Stores the value of the alpha mode
  20599. */
  20600. private _alphaMode;
  20601. /**
  20602. * Sets the value of the alpha mode.
  20603. *
  20604. * | Value | Type | Description |
  20605. * | --- | --- | --- |
  20606. * | 0 | ALPHA_DISABLE | |
  20607. * | 1 | ALPHA_ADD | |
  20608. * | 2 | ALPHA_COMBINE | |
  20609. * | 3 | ALPHA_SUBTRACT | |
  20610. * | 4 | ALPHA_MULTIPLY | |
  20611. * | 5 | ALPHA_MAXIMIZED | |
  20612. * | 6 | ALPHA_ONEONE | |
  20613. * | 7 | ALPHA_PREMULTIPLIED | |
  20614. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20615. * | 9 | ALPHA_INTERPOLATE | |
  20616. * | 10 | ALPHA_SCREENMODE | |
  20617. *
  20618. */
  20619. /**
  20620. * Gets the value of the alpha mode
  20621. */
  20622. alphaMode: number;
  20623. /**
  20624. * Stores the state of the need depth pre-pass value
  20625. */
  20626. private _needDepthPrePass;
  20627. /**
  20628. * Sets the need depth pre-pass value
  20629. */
  20630. /**
  20631. * Gets the depth pre-pass value
  20632. */
  20633. needDepthPrePass: boolean;
  20634. /**
  20635. * Specifies if depth writing should be disabled
  20636. */
  20637. disableDepthWrite: boolean;
  20638. /**
  20639. * Specifies if depth writing should be forced
  20640. */
  20641. forceDepthWrite: boolean;
  20642. /**
  20643. * Specifies the depth function that should be used. 0 means the default engine function
  20644. */
  20645. depthFunction: number;
  20646. /**
  20647. * Specifies if there should be a separate pass for culling
  20648. */
  20649. separateCullingPass: boolean;
  20650. /**
  20651. * Stores the state specifing if fog should be enabled
  20652. */
  20653. private _fogEnabled;
  20654. /**
  20655. * Sets the state for enabling fog
  20656. */
  20657. /**
  20658. * Gets the value of the fog enabled state
  20659. */
  20660. fogEnabled: boolean;
  20661. /**
  20662. * Stores the size of points
  20663. */
  20664. pointSize: number;
  20665. /**
  20666. * Stores the z offset value
  20667. */
  20668. zOffset: number;
  20669. /**
  20670. * Gets a value specifying if wireframe mode is enabled
  20671. */
  20672. /**
  20673. * Sets the state of wireframe mode
  20674. */
  20675. wireframe: boolean;
  20676. /**
  20677. * Gets the value specifying if point clouds are enabled
  20678. */
  20679. /**
  20680. * Sets the state of point cloud mode
  20681. */
  20682. pointsCloud: boolean;
  20683. /**
  20684. * Gets the material fill mode
  20685. */
  20686. /**
  20687. * Sets the material fill mode
  20688. */
  20689. fillMode: number;
  20690. /**
  20691. * @hidden
  20692. * Stores the effects for the material
  20693. */
  20694. _effect: Nullable<Effect>;
  20695. /**
  20696. * @hidden
  20697. * Specifies if the material was previously ready
  20698. */
  20699. _wasPreviouslyReady: boolean;
  20700. /**
  20701. * Specifies if uniform buffers should be used
  20702. */
  20703. private _useUBO;
  20704. /**
  20705. * Stores a reference to the scene
  20706. */
  20707. private _scene;
  20708. /**
  20709. * Stores the fill mode state
  20710. */
  20711. private _fillMode;
  20712. /**
  20713. * Specifies if the depth write state should be cached
  20714. */
  20715. private _cachedDepthWriteState;
  20716. /**
  20717. * Specifies if the depth function state should be cached
  20718. */
  20719. private _cachedDepthFunctionState;
  20720. /**
  20721. * Stores the uniform buffer
  20722. */
  20723. protected _uniformBuffer: UniformBuffer;
  20724. /** @hidden */
  20725. _indexInSceneMaterialArray: number;
  20726. /** @hidden */
  20727. meshMap: Nullable<{
  20728. [id: string]: AbstractMesh | undefined;
  20729. }>;
  20730. /**
  20731. * Creates a material instance
  20732. * @param name defines the name of the material
  20733. * @param scene defines the scene to reference
  20734. * @param doNotAdd specifies if the material should be added to the scene
  20735. */
  20736. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20737. /**
  20738. * Returns a string representation of the current material
  20739. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20740. * @returns a string with material information
  20741. */
  20742. toString(fullDetails?: boolean): string;
  20743. /**
  20744. * Gets the class name of the material
  20745. * @returns a string with the class name of the material
  20746. */
  20747. getClassName(): string;
  20748. /**
  20749. * Specifies if updates for the material been locked
  20750. */
  20751. readonly isFrozen: boolean;
  20752. /**
  20753. * Locks updates for the material
  20754. */
  20755. freeze(): void;
  20756. /**
  20757. * Unlocks updates for the material
  20758. */
  20759. unfreeze(): void;
  20760. /**
  20761. * Specifies if the material is ready to be used
  20762. * @param mesh defines the mesh to check
  20763. * @param useInstances specifies if instances should be used
  20764. * @returns a boolean indicating if the material is ready to be used
  20765. */
  20766. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20767. /**
  20768. * Specifies that the submesh is ready to be used
  20769. * @param mesh defines the mesh to check
  20770. * @param subMesh defines which submesh to check
  20771. * @param useInstances specifies that instances should be used
  20772. * @returns a boolean indicating that the submesh is ready or not
  20773. */
  20774. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20775. /**
  20776. * Returns the material effect
  20777. * @returns the effect associated with the material
  20778. */
  20779. getEffect(): Nullable<Effect>;
  20780. /**
  20781. * Returns the current scene
  20782. * @returns a Scene
  20783. */
  20784. getScene(): Scene;
  20785. /**
  20786. * Specifies if the material will require alpha blending
  20787. * @returns a boolean specifying if alpha blending is needed
  20788. */
  20789. needAlphaBlending(): boolean;
  20790. /**
  20791. * Specifies if the mesh will require alpha blending
  20792. * @param mesh defines the mesh to check
  20793. * @returns a boolean specifying if alpha blending is needed for the mesh
  20794. */
  20795. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20796. /**
  20797. * Specifies if this material should be rendered in alpha test mode
  20798. * @returns a boolean specifying if an alpha test is needed.
  20799. */
  20800. needAlphaTesting(): boolean;
  20801. /**
  20802. * Gets the texture used for the alpha test
  20803. * @returns the texture to use for alpha testing
  20804. */
  20805. getAlphaTestTexture(): Nullable<BaseTexture>;
  20806. /**
  20807. * Marks the material to indicate that it needs to be re-calculated
  20808. */
  20809. markDirty(): void;
  20810. /** @hidden */
  20811. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20812. /**
  20813. * Binds the material to the mesh
  20814. * @param world defines the world transformation matrix
  20815. * @param mesh defines the mesh to bind the material to
  20816. */
  20817. bind(world: Matrix, mesh?: Mesh): void;
  20818. /**
  20819. * Binds the submesh to the material
  20820. * @param world defines the world transformation matrix
  20821. * @param mesh defines the mesh containing the submesh
  20822. * @param subMesh defines the submesh to bind the material to
  20823. */
  20824. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20825. /**
  20826. * Binds the world matrix to the material
  20827. * @param world defines the world transformation matrix
  20828. */
  20829. bindOnlyWorldMatrix(world: Matrix): void;
  20830. /**
  20831. * Binds the scene's uniform buffer to the effect.
  20832. * @param effect defines the effect to bind to the scene uniform buffer
  20833. * @param sceneUbo defines the uniform buffer storing scene data
  20834. */
  20835. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20836. /**
  20837. * Binds the view matrix to the effect
  20838. * @param effect defines the effect to bind the view matrix to
  20839. */
  20840. bindView(effect: Effect): void;
  20841. /**
  20842. * Binds the view projection matrix to the effect
  20843. * @param effect defines the effect to bind the view projection matrix to
  20844. */
  20845. bindViewProjection(effect: Effect): void;
  20846. /**
  20847. * Specifies if material alpha testing should be turned on for the mesh
  20848. * @param mesh defines the mesh to check
  20849. */
  20850. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20851. /**
  20852. * Processes to execute after binding the material to a mesh
  20853. * @param mesh defines the rendered mesh
  20854. */
  20855. protected _afterBind(mesh?: Mesh): void;
  20856. /**
  20857. * Unbinds the material from the mesh
  20858. */
  20859. unbind(): void;
  20860. /**
  20861. * Gets the active textures from the material
  20862. * @returns an array of textures
  20863. */
  20864. getActiveTextures(): BaseTexture[];
  20865. /**
  20866. * Specifies if the material uses a texture
  20867. * @param texture defines the texture to check against the material
  20868. * @returns a boolean specifying if the material uses the texture
  20869. */
  20870. hasTexture(texture: BaseTexture): boolean;
  20871. /**
  20872. * Makes a duplicate of the material, and gives it a new name
  20873. * @param name defines the new name for the duplicated material
  20874. * @returns the cloned material
  20875. */
  20876. clone(name: string): Nullable<Material>;
  20877. /**
  20878. * Gets the meshes bound to the material
  20879. * @returns an array of meshes bound to the material
  20880. */
  20881. getBindedMeshes(): AbstractMesh[];
  20882. /**
  20883. * Force shader compilation
  20884. * @param mesh defines the mesh associated with this material
  20885. * @param onCompiled defines a function to execute once the material is compiled
  20886. * @param options defines the options to configure the compilation
  20887. * @param onError defines a function to execute if the material fails compiling
  20888. */
  20889. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  20890. /**
  20891. * Force shader compilation
  20892. * @param mesh defines the mesh that will use this material
  20893. * @param options defines additional options for compiling the shaders
  20894. * @returns a promise that resolves when the compilation completes
  20895. */
  20896. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  20897. private static readonly _AllDirtyCallBack;
  20898. private static readonly _ImageProcessingDirtyCallBack;
  20899. private static readonly _TextureDirtyCallBack;
  20900. private static readonly _FresnelDirtyCallBack;
  20901. private static readonly _MiscDirtyCallBack;
  20902. private static readonly _LightsDirtyCallBack;
  20903. private static readonly _AttributeDirtyCallBack;
  20904. private static _FresnelAndMiscDirtyCallBack;
  20905. private static _TextureAndMiscDirtyCallBack;
  20906. private static readonly _DirtyCallbackArray;
  20907. private static readonly _RunDirtyCallBacks;
  20908. /**
  20909. * Marks a define in the material to indicate that it needs to be re-computed
  20910. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20911. */
  20912. markAsDirty(flag: number): void;
  20913. /**
  20914. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20915. * @param func defines a function which checks material defines against the submeshes
  20916. */
  20917. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20918. /**
  20919. * Indicates that we need to re-calculated for all submeshes
  20920. */
  20921. protected _markAllSubMeshesAsAllDirty(): void;
  20922. /**
  20923. * Indicates that image processing needs to be re-calculated for all submeshes
  20924. */
  20925. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20926. /**
  20927. * Indicates that textures need to be re-calculated for all submeshes
  20928. */
  20929. protected _markAllSubMeshesAsTexturesDirty(): void;
  20930. /**
  20931. * Indicates that fresnel needs to be re-calculated for all submeshes
  20932. */
  20933. protected _markAllSubMeshesAsFresnelDirty(): void;
  20934. /**
  20935. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20936. */
  20937. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20938. /**
  20939. * Indicates that lights need to be re-calculated for all submeshes
  20940. */
  20941. protected _markAllSubMeshesAsLightsDirty(): void;
  20942. /**
  20943. * Indicates that attributes need to be re-calculated for all submeshes
  20944. */
  20945. protected _markAllSubMeshesAsAttributesDirty(): void;
  20946. /**
  20947. * Indicates that misc needs to be re-calculated for all submeshes
  20948. */
  20949. protected _markAllSubMeshesAsMiscDirty(): void;
  20950. /**
  20951. * Indicates that textures and misc need to be re-calculated for all submeshes
  20952. */
  20953. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20954. /**
  20955. * Disposes the material
  20956. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20957. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20958. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20959. */
  20960. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20961. /** @hidden */
  20962. private releaseVertexArrayObject;
  20963. /**
  20964. * Serializes this material
  20965. * @returns the serialized material object
  20966. */
  20967. serialize(): any;
  20968. /**
  20969. * Creates a material from parsed material data
  20970. * @param parsedMaterial defines parsed material data
  20971. * @param scene defines the hosting scene
  20972. * @param rootUrl defines the root URL to use to load textures
  20973. * @returns a new material
  20974. */
  20975. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20976. }
  20977. }
  20978. declare module BABYLON {
  20979. /**
  20980. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20981. * separate meshes. This can be use to improve performances.
  20982. * @see http://doc.babylonjs.com/how_to/multi_materials
  20983. */
  20984. export class MultiMaterial extends Material {
  20985. private _subMaterials;
  20986. /**
  20987. * Gets or Sets the list of Materials used within the multi material.
  20988. * They need to be ordered according to the submeshes order in the associated mesh
  20989. */
  20990. subMaterials: Nullable<Material>[];
  20991. /**
  20992. * Function used to align with Node.getChildren()
  20993. * @returns the list of Materials used within the multi material
  20994. */
  20995. getChildren(): Nullable<Material>[];
  20996. /**
  20997. * Instantiates a new Multi Material
  20998. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20999. * separate meshes. This can be use to improve performances.
  21000. * @see http://doc.babylonjs.com/how_to/multi_materials
  21001. * @param name Define the name in the scene
  21002. * @param scene Define the scene the material belongs to
  21003. */
  21004. constructor(name: string, scene: Scene);
  21005. private _hookArray;
  21006. /**
  21007. * Get one of the submaterial by its index in the submaterials array
  21008. * @param index The index to look the sub material at
  21009. * @returns The Material if the index has been defined
  21010. */
  21011. getSubMaterial(index: number): Nullable<Material>;
  21012. /**
  21013. * Get the list of active textures for the whole sub materials list.
  21014. * @returns All the textures that will be used during the rendering
  21015. */
  21016. getActiveTextures(): BaseTexture[];
  21017. /**
  21018. * Gets the current class name of the material e.g. "MultiMaterial"
  21019. * Mainly use in serialization.
  21020. * @returns the class name
  21021. */
  21022. getClassName(): string;
  21023. /**
  21024. * Checks if the material is ready to render the requested sub mesh
  21025. * @param mesh Define the mesh the submesh belongs to
  21026. * @param subMesh Define the sub mesh to look readyness for
  21027. * @param useInstances Define whether or not the material is used with instances
  21028. * @returns true if ready, otherwise false
  21029. */
  21030. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21031. /**
  21032. * Clones the current material and its related sub materials
  21033. * @param name Define the name of the newly cloned material
  21034. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21035. * @returns the cloned material
  21036. */
  21037. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21038. /**
  21039. * Serializes the materials into a JSON representation.
  21040. * @returns the JSON representation
  21041. */
  21042. serialize(): any;
  21043. /**
  21044. * Dispose the material and release its associated resources
  21045. * @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)
  21046. * @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)
  21047. * @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)
  21048. */
  21049. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21050. /**
  21051. * Creates a MultiMaterial from parsed MultiMaterial data.
  21052. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21053. * @param scene defines the hosting scene
  21054. * @returns a new MultiMaterial
  21055. */
  21056. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21057. }
  21058. }
  21059. declare module BABYLON {
  21060. /**
  21061. * Base class for submeshes
  21062. */
  21063. export class BaseSubMesh {
  21064. /** @hidden */
  21065. _materialDefines: Nullable<MaterialDefines>;
  21066. /** @hidden */
  21067. _materialEffect: Nullable<Effect>;
  21068. /**
  21069. * Gets material defines used by the effect associated to the sub mesh
  21070. */
  21071. /**
  21072. * Sets material defines used by the effect associated to the sub mesh
  21073. */
  21074. materialDefines: Nullable<MaterialDefines>;
  21075. /**
  21076. * Gets associated effect
  21077. */
  21078. readonly effect: Nullable<Effect>;
  21079. /**
  21080. * Sets associated effect (effect used to render this submesh)
  21081. * @param effect defines the effect to associate with
  21082. * @param defines defines the set of defines used to compile this effect
  21083. */
  21084. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21085. }
  21086. /**
  21087. * Defines a subdivision inside a mesh
  21088. */
  21089. export class SubMesh extends BaseSubMesh implements ICullable {
  21090. /** the material index to use */
  21091. materialIndex: number;
  21092. /** vertex index start */
  21093. verticesStart: number;
  21094. /** vertices count */
  21095. verticesCount: number;
  21096. /** index start */
  21097. indexStart: number;
  21098. /** indices count */
  21099. indexCount: number;
  21100. /** @hidden */
  21101. _linesIndexCount: number;
  21102. private _mesh;
  21103. private _renderingMesh;
  21104. private _boundingInfo;
  21105. private _linesIndexBuffer;
  21106. /** @hidden */
  21107. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21108. /** @hidden */
  21109. _trianglePlanes: Plane[];
  21110. /** @hidden */
  21111. _lastColliderTransformMatrix: Nullable<Matrix>;
  21112. /** @hidden */
  21113. _renderId: number;
  21114. /** @hidden */
  21115. _alphaIndex: number;
  21116. /** @hidden */
  21117. _distanceToCamera: number;
  21118. /** @hidden */
  21119. _id: number;
  21120. private _currentMaterial;
  21121. /**
  21122. * Add a new submesh to a mesh
  21123. * @param materialIndex defines the material index to use
  21124. * @param verticesStart defines vertex index start
  21125. * @param verticesCount defines vertices count
  21126. * @param indexStart defines index start
  21127. * @param indexCount defines indices count
  21128. * @param mesh defines the parent mesh
  21129. * @param renderingMesh defines an optional rendering mesh
  21130. * @param createBoundingBox defines if bounding box should be created for this submesh
  21131. * @returns the new submesh
  21132. */
  21133. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21134. /**
  21135. * Creates a new submesh
  21136. * @param materialIndex defines the material index to use
  21137. * @param verticesStart defines vertex index start
  21138. * @param verticesCount defines vertices count
  21139. * @param indexStart defines index start
  21140. * @param indexCount defines indices count
  21141. * @param mesh defines the parent mesh
  21142. * @param renderingMesh defines an optional rendering mesh
  21143. * @param createBoundingBox defines if bounding box should be created for this submesh
  21144. */
  21145. constructor(
  21146. /** the material index to use */
  21147. materialIndex: number,
  21148. /** vertex index start */
  21149. verticesStart: number,
  21150. /** vertices count */
  21151. verticesCount: number,
  21152. /** index start */
  21153. indexStart: number,
  21154. /** indices count */
  21155. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21156. /**
  21157. * Returns true if this submesh covers the entire parent mesh
  21158. * @ignorenaming
  21159. */
  21160. readonly IsGlobal: boolean;
  21161. /**
  21162. * Returns the submesh BoudingInfo object
  21163. * @returns current bounding info (or mesh's one if the submesh is global)
  21164. */
  21165. getBoundingInfo(): BoundingInfo;
  21166. /**
  21167. * Sets the submesh BoundingInfo
  21168. * @param boundingInfo defines the new bounding info to use
  21169. * @returns the SubMesh
  21170. */
  21171. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21172. /**
  21173. * Returns the mesh of the current submesh
  21174. * @return the parent mesh
  21175. */
  21176. getMesh(): AbstractMesh;
  21177. /**
  21178. * Returns the rendering mesh of the submesh
  21179. * @returns the rendering mesh (could be different from parent mesh)
  21180. */
  21181. getRenderingMesh(): Mesh;
  21182. /**
  21183. * Returns the submesh material
  21184. * @returns null or the current material
  21185. */
  21186. getMaterial(): Nullable<Material>;
  21187. /**
  21188. * Sets a new updated BoundingInfo object to the submesh
  21189. * @param data defines an optional position array to use to determine the bounding info
  21190. * @returns the SubMesh
  21191. */
  21192. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21193. /** @hidden */
  21194. _checkCollision(collider: Collider): boolean;
  21195. /**
  21196. * Updates the submesh BoundingInfo
  21197. * @param world defines the world matrix to use to update the bounding info
  21198. * @returns the submesh
  21199. */
  21200. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21201. /**
  21202. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21203. * @param frustumPlanes defines the frustum planes
  21204. * @returns true if the submesh is intersecting with the frustum
  21205. */
  21206. isInFrustum(frustumPlanes: Plane[]): boolean;
  21207. /**
  21208. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21209. * @param frustumPlanes defines the frustum planes
  21210. * @returns true if the submesh is inside the frustum
  21211. */
  21212. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21213. /**
  21214. * Renders the submesh
  21215. * @param enableAlphaMode defines if alpha needs to be used
  21216. * @returns the submesh
  21217. */
  21218. render(enableAlphaMode: boolean): SubMesh;
  21219. /**
  21220. * @hidden
  21221. */
  21222. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21223. /**
  21224. * Checks if the submesh intersects with a ray
  21225. * @param ray defines the ray to test
  21226. * @returns true is the passed ray intersects the submesh bounding box
  21227. */
  21228. canIntersects(ray: Ray): boolean;
  21229. /**
  21230. * Intersects current submesh with a ray
  21231. * @param ray defines the ray to test
  21232. * @param positions defines mesh's positions array
  21233. * @param indices defines mesh's indices array
  21234. * @param fastCheck defines if only bounding info should be used
  21235. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21236. * @returns intersection info or null if no intersection
  21237. */
  21238. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21239. /** @hidden */
  21240. private _intersectLines;
  21241. /** @hidden */
  21242. private _intersectUnIndexedLines;
  21243. /** @hidden */
  21244. private _intersectTriangles;
  21245. /** @hidden */
  21246. private _intersectUnIndexedTriangles;
  21247. /** @hidden */
  21248. _rebuild(): void;
  21249. /**
  21250. * Creates a new submesh from the passed mesh
  21251. * @param newMesh defines the new hosting mesh
  21252. * @param newRenderingMesh defines an optional rendering mesh
  21253. * @returns the new submesh
  21254. */
  21255. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21256. /**
  21257. * Release associated resources
  21258. */
  21259. dispose(): void;
  21260. /**
  21261. * Gets the class name
  21262. * @returns the string "SubMesh".
  21263. */
  21264. getClassName(): string;
  21265. /**
  21266. * Creates a new submesh from indices data
  21267. * @param materialIndex the index of the main mesh material
  21268. * @param startIndex the index where to start the copy in the mesh indices array
  21269. * @param indexCount the number of indices to copy then from the startIndex
  21270. * @param mesh the main mesh to create the submesh from
  21271. * @param renderingMesh the optional rendering mesh
  21272. * @returns a new submesh
  21273. */
  21274. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21275. }
  21276. }
  21277. declare module BABYLON {
  21278. /**
  21279. * Class used to represent data loading progression
  21280. */
  21281. export class SceneLoaderFlags {
  21282. private static _ForceFullSceneLoadingForIncremental;
  21283. private static _ShowLoadingScreen;
  21284. private static _CleanBoneMatrixWeights;
  21285. private static _loggingLevel;
  21286. /**
  21287. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21288. */
  21289. static ForceFullSceneLoadingForIncremental: boolean;
  21290. /**
  21291. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21292. */
  21293. static ShowLoadingScreen: boolean;
  21294. /**
  21295. * Defines the current logging level (while loading the scene)
  21296. * @ignorenaming
  21297. */
  21298. static loggingLevel: number;
  21299. /**
  21300. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21301. */
  21302. static CleanBoneMatrixWeights: boolean;
  21303. }
  21304. }
  21305. declare module BABYLON {
  21306. /**
  21307. * Class used to store geometry data (vertex buffers + index buffer)
  21308. */
  21309. export class Geometry implements IGetSetVerticesData {
  21310. /**
  21311. * Gets or sets the ID of the geometry
  21312. */
  21313. id: string;
  21314. /**
  21315. * Gets or sets the unique ID of the geometry
  21316. */
  21317. uniqueId: number;
  21318. /**
  21319. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21320. */
  21321. delayLoadState: number;
  21322. /**
  21323. * Gets the file containing the data to load when running in delay load state
  21324. */
  21325. delayLoadingFile: Nullable<string>;
  21326. /**
  21327. * Callback called when the geometry is updated
  21328. */
  21329. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21330. private _scene;
  21331. private _engine;
  21332. private _meshes;
  21333. private _totalVertices;
  21334. /** @hidden */
  21335. _indices: IndicesArray;
  21336. /** @hidden */
  21337. _vertexBuffers: {
  21338. [key: string]: VertexBuffer;
  21339. };
  21340. private _isDisposed;
  21341. private _extend;
  21342. private _boundingBias;
  21343. /** @hidden */
  21344. _delayInfo: Array<string>;
  21345. private _indexBuffer;
  21346. private _indexBufferIsUpdatable;
  21347. /** @hidden */
  21348. _boundingInfo: Nullable<BoundingInfo>;
  21349. /** @hidden */
  21350. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21351. /** @hidden */
  21352. _softwareSkinningFrameId: number;
  21353. private _vertexArrayObjects;
  21354. private _updatable;
  21355. /** @hidden */
  21356. _positions: Nullable<Vector3[]>;
  21357. /**
  21358. * 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
  21359. */
  21360. /**
  21361. * 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
  21362. */
  21363. boundingBias: Vector2;
  21364. /**
  21365. * Static function used to attach a new empty geometry to a mesh
  21366. * @param mesh defines the mesh to attach the geometry to
  21367. * @returns the new Geometry
  21368. */
  21369. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21370. /**
  21371. * Creates a new geometry
  21372. * @param id defines the unique ID
  21373. * @param scene defines the hosting scene
  21374. * @param vertexData defines the VertexData used to get geometry data
  21375. * @param updatable defines if geometry must be updatable (false by default)
  21376. * @param mesh defines the mesh that will be associated with the geometry
  21377. */
  21378. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21379. /**
  21380. * Gets the current extend of the geometry
  21381. */
  21382. readonly extend: {
  21383. minimum: Vector3;
  21384. maximum: Vector3;
  21385. };
  21386. /**
  21387. * Gets the hosting scene
  21388. * @returns the hosting Scene
  21389. */
  21390. getScene(): Scene;
  21391. /**
  21392. * Gets the hosting engine
  21393. * @returns the hosting Engine
  21394. */
  21395. getEngine(): Engine;
  21396. /**
  21397. * Defines if the geometry is ready to use
  21398. * @returns true if the geometry is ready to be used
  21399. */
  21400. isReady(): boolean;
  21401. /**
  21402. * Gets a value indicating that the geometry should not be serialized
  21403. */
  21404. readonly doNotSerialize: boolean;
  21405. /** @hidden */
  21406. _rebuild(): void;
  21407. /**
  21408. * Affects all geometry data in one call
  21409. * @param vertexData defines the geometry data
  21410. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21411. */
  21412. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21413. /**
  21414. * Set specific vertex data
  21415. * @param kind defines the data kind (Position, normal, etc...)
  21416. * @param data defines the vertex data to use
  21417. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21418. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21419. */
  21420. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21421. /**
  21422. * Removes a specific vertex data
  21423. * @param kind defines the data kind (Position, normal, etc...)
  21424. */
  21425. removeVerticesData(kind: string): void;
  21426. /**
  21427. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21428. * @param buffer defines the vertex buffer to use
  21429. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21430. */
  21431. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21432. /**
  21433. * Update a specific vertex buffer
  21434. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21435. * It will do nothing if the buffer is not updatable
  21436. * @param kind defines the data kind (Position, normal, etc...)
  21437. * @param data defines the data to use
  21438. * @param offset defines the offset in the target buffer where to store the data
  21439. * @param useBytes set to true if the offset is in bytes
  21440. */
  21441. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21442. /**
  21443. * Update a specific vertex buffer
  21444. * This function will create a new buffer if the current one is not updatable
  21445. * @param kind defines the data kind (Position, normal, etc...)
  21446. * @param data defines the data to use
  21447. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21448. */
  21449. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21450. private _updateBoundingInfo;
  21451. /** @hidden */
  21452. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21453. /**
  21454. * Gets total number of vertices
  21455. * @returns the total number of vertices
  21456. */
  21457. getTotalVertices(): number;
  21458. /**
  21459. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21460. * @param kind defines the data kind (Position, normal, etc...)
  21461. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21462. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21463. * @returns a float array containing vertex data
  21464. */
  21465. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21466. /**
  21467. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21468. * @param kind defines the data kind (Position, normal, etc...)
  21469. * @returns true if the vertex buffer with the specified kind is updatable
  21470. */
  21471. isVertexBufferUpdatable(kind: string): boolean;
  21472. /**
  21473. * Gets a specific vertex buffer
  21474. * @param kind defines the data kind (Position, normal, etc...)
  21475. * @returns a VertexBuffer
  21476. */
  21477. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21478. /**
  21479. * Returns all vertex buffers
  21480. * @return an object holding all vertex buffers indexed by kind
  21481. */
  21482. getVertexBuffers(): Nullable<{
  21483. [key: string]: VertexBuffer;
  21484. }>;
  21485. /**
  21486. * Gets a boolean indicating if specific vertex buffer is present
  21487. * @param kind defines the data kind (Position, normal, etc...)
  21488. * @returns true if data is present
  21489. */
  21490. isVerticesDataPresent(kind: string): boolean;
  21491. /**
  21492. * Gets a list of all attached data kinds (Position, normal, etc...)
  21493. * @returns a list of string containing all kinds
  21494. */
  21495. getVerticesDataKinds(): string[];
  21496. /**
  21497. * Update index buffer
  21498. * @param indices defines the indices to store in the index buffer
  21499. * @param offset defines the offset in the target buffer where to store the data
  21500. * @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)
  21501. */
  21502. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21503. /**
  21504. * Creates a new index buffer
  21505. * @param indices defines the indices to store in the index buffer
  21506. * @param totalVertices defines the total number of vertices (could be null)
  21507. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21508. */
  21509. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21510. /**
  21511. * Return the total number of indices
  21512. * @returns the total number of indices
  21513. */
  21514. getTotalIndices(): number;
  21515. /**
  21516. * Gets the index buffer array
  21517. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21518. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21519. * @returns the index buffer array
  21520. */
  21521. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21522. /**
  21523. * Gets the index buffer
  21524. * @return the index buffer
  21525. */
  21526. getIndexBuffer(): Nullable<DataBuffer>;
  21527. /** @hidden */
  21528. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21529. /**
  21530. * Release the associated resources for a specific mesh
  21531. * @param mesh defines the source mesh
  21532. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21533. */
  21534. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21535. /**
  21536. * Apply current geometry to a given mesh
  21537. * @param mesh defines the mesh to apply geometry to
  21538. */
  21539. applyToMesh(mesh: Mesh): void;
  21540. private _updateExtend;
  21541. private _applyToMesh;
  21542. private notifyUpdate;
  21543. /**
  21544. * Load the geometry if it was flagged as delay loaded
  21545. * @param scene defines the hosting scene
  21546. * @param onLoaded defines a callback called when the geometry is loaded
  21547. */
  21548. load(scene: Scene, onLoaded?: () => void): void;
  21549. private _queueLoad;
  21550. /**
  21551. * Invert the geometry to move from a right handed system to a left handed one.
  21552. */
  21553. toLeftHanded(): void;
  21554. /** @hidden */
  21555. _resetPointsArrayCache(): void;
  21556. /** @hidden */
  21557. _generatePointsArray(): boolean;
  21558. /**
  21559. * Gets a value indicating if the geometry is disposed
  21560. * @returns true if the geometry was disposed
  21561. */
  21562. isDisposed(): boolean;
  21563. private _disposeVertexArrayObjects;
  21564. /**
  21565. * Free all associated resources
  21566. */
  21567. dispose(): void;
  21568. /**
  21569. * Clone the current geometry into a new geometry
  21570. * @param id defines the unique ID of the new geometry
  21571. * @returns a new geometry object
  21572. */
  21573. copy(id: string): Geometry;
  21574. /**
  21575. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21576. * @return a JSON representation of the current geometry data (without the vertices data)
  21577. */
  21578. serialize(): any;
  21579. private toNumberArray;
  21580. /**
  21581. * Serialize all vertices data into a JSON oject
  21582. * @returns a JSON representation of the current geometry data
  21583. */
  21584. serializeVerticeData(): any;
  21585. /**
  21586. * Extracts a clone of a mesh geometry
  21587. * @param mesh defines the source mesh
  21588. * @param id defines the unique ID of the new geometry object
  21589. * @returns the new geometry object
  21590. */
  21591. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21592. /**
  21593. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21594. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21595. * Be aware Math.random() could cause collisions, but:
  21596. * "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"
  21597. * @returns a string containing a new GUID
  21598. */
  21599. static RandomId(): string;
  21600. /** @hidden */
  21601. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21602. private static _CleanMatricesWeights;
  21603. /**
  21604. * Create a new geometry from persisted data (Using .babylon file format)
  21605. * @param parsedVertexData defines the persisted data
  21606. * @param scene defines the hosting scene
  21607. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21608. * @returns the new geometry object
  21609. */
  21610. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21611. }
  21612. }
  21613. declare module BABYLON {
  21614. /**
  21615. * Define an interface for all classes that will get and set the data on vertices
  21616. */
  21617. export interface IGetSetVerticesData {
  21618. /**
  21619. * Gets a boolean indicating if specific vertex data is present
  21620. * @param kind defines the vertex data kind to use
  21621. * @returns true is data kind is present
  21622. */
  21623. isVerticesDataPresent(kind: string): boolean;
  21624. /**
  21625. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21626. * @param kind defines the data kind (Position, normal, etc...)
  21627. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21628. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21629. * @returns a float array containing vertex data
  21630. */
  21631. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21632. /**
  21633. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21634. * @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.
  21635. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21636. * @returns the indices array or an empty array if the mesh has no geometry
  21637. */
  21638. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21639. /**
  21640. * Set specific vertex data
  21641. * @param kind defines the data kind (Position, normal, etc...)
  21642. * @param data defines the vertex data to use
  21643. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21644. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21645. */
  21646. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21647. /**
  21648. * Update a specific associated vertex buffer
  21649. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21650. * - VertexBuffer.PositionKind
  21651. * - VertexBuffer.UVKind
  21652. * - VertexBuffer.UV2Kind
  21653. * - VertexBuffer.UV3Kind
  21654. * - VertexBuffer.UV4Kind
  21655. * - VertexBuffer.UV5Kind
  21656. * - VertexBuffer.UV6Kind
  21657. * - VertexBuffer.ColorKind
  21658. * - VertexBuffer.MatricesIndicesKind
  21659. * - VertexBuffer.MatricesIndicesExtraKind
  21660. * - VertexBuffer.MatricesWeightsKind
  21661. * - VertexBuffer.MatricesWeightsExtraKind
  21662. * @param data defines the data source
  21663. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21664. * @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)
  21665. */
  21666. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21667. /**
  21668. * Creates a new index buffer
  21669. * @param indices defines the indices to store in the index buffer
  21670. * @param totalVertices defines the total number of vertices (could be null)
  21671. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21672. */
  21673. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21674. }
  21675. /**
  21676. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21677. */
  21678. export class VertexData {
  21679. /**
  21680. * Mesh side orientation : usually the external or front surface
  21681. */
  21682. static readonly FRONTSIDE: number;
  21683. /**
  21684. * Mesh side orientation : usually the internal or back surface
  21685. */
  21686. static readonly BACKSIDE: number;
  21687. /**
  21688. * Mesh side orientation : both internal and external or front and back surfaces
  21689. */
  21690. static readonly DOUBLESIDE: number;
  21691. /**
  21692. * Mesh side orientation : by default, `FRONTSIDE`
  21693. */
  21694. static readonly DEFAULTSIDE: number;
  21695. /**
  21696. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21697. */
  21698. positions: Nullable<FloatArray>;
  21699. /**
  21700. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21701. */
  21702. normals: Nullable<FloatArray>;
  21703. /**
  21704. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21705. */
  21706. tangents: Nullable<FloatArray>;
  21707. /**
  21708. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21709. */
  21710. uvs: Nullable<FloatArray>;
  21711. /**
  21712. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21713. */
  21714. uvs2: Nullable<FloatArray>;
  21715. /**
  21716. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21717. */
  21718. uvs3: Nullable<FloatArray>;
  21719. /**
  21720. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21721. */
  21722. uvs4: Nullable<FloatArray>;
  21723. /**
  21724. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21725. */
  21726. uvs5: Nullable<FloatArray>;
  21727. /**
  21728. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21729. */
  21730. uvs6: Nullable<FloatArray>;
  21731. /**
  21732. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21733. */
  21734. colors: Nullable<FloatArray>;
  21735. /**
  21736. * 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).
  21737. */
  21738. matricesIndices: Nullable<FloatArray>;
  21739. /**
  21740. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21741. */
  21742. matricesWeights: Nullable<FloatArray>;
  21743. /**
  21744. * An array extending the number of possible indices
  21745. */
  21746. matricesIndicesExtra: Nullable<FloatArray>;
  21747. /**
  21748. * An array extending the number of possible weights when the number of indices is extended
  21749. */
  21750. matricesWeightsExtra: Nullable<FloatArray>;
  21751. /**
  21752. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21753. */
  21754. indices: Nullable<IndicesArray>;
  21755. /**
  21756. * Uses the passed data array to set the set the values for the specified kind of data
  21757. * @param data a linear array of floating numbers
  21758. * @param kind the type of data that is being set, eg positions, colors etc
  21759. */
  21760. set(data: FloatArray, kind: string): void;
  21761. /**
  21762. * Associates the vertexData to the passed Mesh.
  21763. * Sets it as updatable or not (default `false`)
  21764. * @param mesh the mesh the vertexData is applied to
  21765. * @param updatable when used and having the value true allows new data to update the vertexData
  21766. * @returns the VertexData
  21767. */
  21768. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21769. /**
  21770. * Associates the vertexData to the passed Geometry.
  21771. * Sets it as updatable or not (default `false`)
  21772. * @param geometry the geometry the vertexData is applied to
  21773. * @param updatable when used and having the value true allows new data to update the vertexData
  21774. * @returns VertexData
  21775. */
  21776. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21777. /**
  21778. * Updates the associated mesh
  21779. * @param mesh the mesh to be updated
  21780. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21781. * @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
  21782. * @returns VertexData
  21783. */
  21784. updateMesh(mesh: Mesh): VertexData;
  21785. /**
  21786. * Updates the associated geometry
  21787. * @param geometry the geometry to be updated
  21788. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21789. * @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
  21790. * @returns VertexData.
  21791. */
  21792. updateGeometry(geometry: Geometry): VertexData;
  21793. private _applyTo;
  21794. private _update;
  21795. /**
  21796. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21797. * @param matrix the transforming matrix
  21798. * @returns the VertexData
  21799. */
  21800. transform(matrix: Matrix): VertexData;
  21801. /**
  21802. * Merges the passed VertexData into the current one
  21803. * @param other the VertexData to be merged into the current one
  21804. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21805. * @returns the modified VertexData
  21806. */
  21807. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21808. private _mergeElement;
  21809. private _validate;
  21810. /**
  21811. * Serializes the VertexData
  21812. * @returns a serialized object
  21813. */
  21814. serialize(): any;
  21815. /**
  21816. * Extracts the vertexData from a mesh
  21817. * @param mesh the mesh from which to extract the VertexData
  21818. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21819. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21820. * @returns the object VertexData associated to the passed mesh
  21821. */
  21822. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21823. /**
  21824. * Extracts the vertexData from the geometry
  21825. * @param geometry the geometry from which to extract the VertexData
  21826. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21827. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21828. * @returns the object VertexData associated to the passed mesh
  21829. */
  21830. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21831. private static _ExtractFrom;
  21832. /**
  21833. * Creates the VertexData for a Ribbon
  21834. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21835. * * pathArray array of paths, each of which an array of successive Vector3
  21836. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21837. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21838. * * 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
  21839. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21840. * * 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)
  21841. * * 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)
  21842. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21843. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21844. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21845. * @returns the VertexData of the ribbon
  21846. */
  21847. static CreateRibbon(options: {
  21848. pathArray: Vector3[][];
  21849. closeArray?: boolean;
  21850. closePath?: boolean;
  21851. offset?: number;
  21852. sideOrientation?: number;
  21853. frontUVs?: Vector4;
  21854. backUVs?: Vector4;
  21855. invertUV?: boolean;
  21856. uvs?: Vector2[];
  21857. colors?: Color4[];
  21858. }): VertexData;
  21859. /**
  21860. * Creates the VertexData for a box
  21861. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21862. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21863. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21864. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21865. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21866. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21867. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21868. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21869. * * 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)
  21870. * * 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)
  21871. * @returns the VertexData of the box
  21872. */
  21873. static CreateBox(options: {
  21874. size?: number;
  21875. width?: number;
  21876. height?: number;
  21877. depth?: number;
  21878. faceUV?: Vector4[];
  21879. faceColors?: Color4[];
  21880. sideOrientation?: number;
  21881. frontUVs?: Vector4;
  21882. backUVs?: Vector4;
  21883. }): VertexData;
  21884. /**
  21885. * Creates the VertexData for a tiled box
  21886. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21887. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21888. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21889. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21890. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21891. * @returns the VertexData of the box
  21892. */
  21893. static CreateTiledBox(options: {
  21894. pattern?: number;
  21895. width?: number;
  21896. height?: number;
  21897. depth?: number;
  21898. tileSize?: number;
  21899. tileWidth?: number;
  21900. tileHeight?: number;
  21901. alignHorizontal?: number;
  21902. alignVertical?: number;
  21903. faceUV?: Vector4[];
  21904. faceColors?: Color4[];
  21905. sideOrientation?: number;
  21906. }): VertexData;
  21907. /**
  21908. * Creates the VertexData for a tiled plane
  21909. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21910. * * pattern a limited pattern arrangement depending on the number
  21911. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21912. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21913. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21914. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21915. * * 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)
  21916. * * 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)
  21917. * @returns the VertexData of the tiled plane
  21918. */
  21919. static CreateTiledPlane(options: {
  21920. pattern?: number;
  21921. tileSize?: number;
  21922. tileWidth?: number;
  21923. tileHeight?: number;
  21924. size?: number;
  21925. width?: number;
  21926. height?: number;
  21927. alignHorizontal?: number;
  21928. alignVertical?: number;
  21929. sideOrientation?: number;
  21930. frontUVs?: Vector4;
  21931. backUVs?: Vector4;
  21932. }): VertexData;
  21933. /**
  21934. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21935. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21936. * * segments sets the number of horizontal strips optional, default 32
  21937. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21938. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21939. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21940. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21941. * * 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
  21942. * * 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
  21943. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21944. * * 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)
  21945. * * 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)
  21946. * @returns the VertexData of the ellipsoid
  21947. */
  21948. static CreateSphere(options: {
  21949. segments?: number;
  21950. diameter?: number;
  21951. diameterX?: number;
  21952. diameterY?: number;
  21953. diameterZ?: number;
  21954. arc?: number;
  21955. slice?: number;
  21956. sideOrientation?: number;
  21957. frontUVs?: Vector4;
  21958. backUVs?: Vector4;
  21959. }): VertexData;
  21960. /**
  21961. * Creates the VertexData for a cylinder, cone or prism
  21962. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21963. * * height sets the height (y direction) of the cylinder, optional, default 2
  21964. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21965. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21966. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21967. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21968. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21969. * * 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
  21970. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21971. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21972. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21973. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21974. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21975. * * 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)
  21976. * * 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)
  21977. * @returns the VertexData of the cylinder, cone or prism
  21978. */
  21979. static CreateCylinder(options: {
  21980. height?: number;
  21981. diameterTop?: number;
  21982. diameterBottom?: number;
  21983. diameter?: number;
  21984. tessellation?: number;
  21985. subdivisions?: number;
  21986. arc?: number;
  21987. faceColors?: Color4[];
  21988. faceUV?: Vector4[];
  21989. hasRings?: boolean;
  21990. enclose?: boolean;
  21991. sideOrientation?: number;
  21992. frontUVs?: Vector4;
  21993. backUVs?: Vector4;
  21994. }): VertexData;
  21995. /**
  21996. * Creates the VertexData for a torus
  21997. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21998. * * diameter the diameter of the torus, optional default 1
  21999. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22000. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22001. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22002. * * 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)
  22003. * * 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)
  22004. * @returns the VertexData of the torus
  22005. */
  22006. static CreateTorus(options: {
  22007. diameter?: number;
  22008. thickness?: number;
  22009. tessellation?: number;
  22010. sideOrientation?: number;
  22011. frontUVs?: Vector4;
  22012. backUVs?: Vector4;
  22013. }): VertexData;
  22014. /**
  22015. * Creates the VertexData of the LineSystem
  22016. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22017. * - lines an array of lines, each line being an array of successive Vector3
  22018. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22019. * @returns the VertexData of the LineSystem
  22020. */
  22021. static CreateLineSystem(options: {
  22022. lines: Vector3[][];
  22023. colors?: Nullable<Color4[][]>;
  22024. }): VertexData;
  22025. /**
  22026. * Create the VertexData for a DashedLines
  22027. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22028. * - points an array successive Vector3
  22029. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22030. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22031. * - dashNb the intended total number of dashes, optional, default 200
  22032. * @returns the VertexData for the DashedLines
  22033. */
  22034. static CreateDashedLines(options: {
  22035. points: Vector3[];
  22036. dashSize?: number;
  22037. gapSize?: number;
  22038. dashNb?: number;
  22039. }): VertexData;
  22040. /**
  22041. * Creates the VertexData for a Ground
  22042. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22043. * - width the width (x direction) of the ground, optional, default 1
  22044. * - height the height (z direction) of the ground, optional, default 1
  22045. * - subdivisions the number of subdivisions per side, optional, default 1
  22046. * @returns the VertexData of the Ground
  22047. */
  22048. static CreateGround(options: {
  22049. width?: number;
  22050. height?: number;
  22051. subdivisions?: number;
  22052. subdivisionsX?: number;
  22053. subdivisionsY?: number;
  22054. }): VertexData;
  22055. /**
  22056. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22057. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22058. * * xmin the ground minimum X coordinate, optional, default -1
  22059. * * zmin the ground minimum Z coordinate, optional, default -1
  22060. * * xmax the ground maximum X coordinate, optional, default 1
  22061. * * zmax the ground maximum Z coordinate, optional, default 1
  22062. * * 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}
  22063. * * 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}
  22064. * @returns the VertexData of the TiledGround
  22065. */
  22066. static CreateTiledGround(options: {
  22067. xmin: number;
  22068. zmin: number;
  22069. xmax: number;
  22070. zmax: number;
  22071. subdivisions?: {
  22072. w: number;
  22073. h: number;
  22074. };
  22075. precision?: {
  22076. w: number;
  22077. h: number;
  22078. };
  22079. }): VertexData;
  22080. /**
  22081. * Creates the VertexData of the Ground designed from a heightmap
  22082. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22083. * * width the width (x direction) of the ground
  22084. * * height the height (z direction) of the ground
  22085. * * subdivisions the number of subdivisions per side
  22086. * * minHeight the minimum altitude on the ground, optional, default 0
  22087. * * maxHeight the maximum altitude on the ground, optional default 1
  22088. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22089. * * buffer the array holding the image color data
  22090. * * bufferWidth the width of image
  22091. * * bufferHeight the height of image
  22092. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22093. * @returns the VertexData of the Ground designed from a heightmap
  22094. */
  22095. static CreateGroundFromHeightMap(options: {
  22096. width: number;
  22097. height: number;
  22098. subdivisions: number;
  22099. minHeight: number;
  22100. maxHeight: number;
  22101. colorFilter: Color3;
  22102. buffer: Uint8Array;
  22103. bufferWidth: number;
  22104. bufferHeight: number;
  22105. alphaFilter: number;
  22106. }): VertexData;
  22107. /**
  22108. * Creates the VertexData for a Plane
  22109. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22110. * * size sets the width and height of the plane to the value of size, optional default 1
  22111. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22112. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22113. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22114. * * 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)
  22115. * * 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)
  22116. * @returns the VertexData of the box
  22117. */
  22118. static CreatePlane(options: {
  22119. size?: number;
  22120. width?: number;
  22121. height?: number;
  22122. sideOrientation?: number;
  22123. frontUVs?: Vector4;
  22124. backUVs?: Vector4;
  22125. }): VertexData;
  22126. /**
  22127. * Creates the VertexData of the Disc or regular Polygon
  22128. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22129. * * radius the radius of the disc, optional default 0.5
  22130. * * tessellation the number of polygon sides, optional, default 64
  22131. * * 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
  22132. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22133. * * 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)
  22134. * * 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)
  22135. * @returns the VertexData of the box
  22136. */
  22137. static CreateDisc(options: {
  22138. radius?: number;
  22139. tessellation?: number;
  22140. arc?: number;
  22141. sideOrientation?: number;
  22142. frontUVs?: Vector4;
  22143. backUVs?: Vector4;
  22144. }): VertexData;
  22145. /**
  22146. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22147. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22148. * @param polygon a mesh built from polygonTriangulation.build()
  22149. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22150. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22151. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22152. * @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)
  22153. * @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)
  22154. * @returns the VertexData of the Polygon
  22155. */
  22156. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22157. /**
  22158. * Creates the VertexData of the IcoSphere
  22159. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22160. * * radius the radius of the IcoSphere, optional default 1
  22161. * * radiusX allows stretching in the x direction, optional, default radius
  22162. * * radiusY allows stretching in the y direction, optional, default radius
  22163. * * radiusZ allows stretching in the z direction, optional, default radius
  22164. * * flat when true creates a flat shaded mesh, optional, default true
  22165. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22166. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22167. * * 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)
  22168. * * 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)
  22169. * @returns the VertexData of the IcoSphere
  22170. */
  22171. static CreateIcoSphere(options: {
  22172. radius?: number;
  22173. radiusX?: number;
  22174. radiusY?: number;
  22175. radiusZ?: number;
  22176. flat?: boolean;
  22177. subdivisions?: number;
  22178. sideOrientation?: number;
  22179. frontUVs?: Vector4;
  22180. backUVs?: Vector4;
  22181. }): VertexData;
  22182. /**
  22183. * Creates the VertexData for a Polyhedron
  22184. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22185. * * type provided types are:
  22186. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22187. * * 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)
  22188. * * size the size of the IcoSphere, optional default 1
  22189. * * sizeX allows stretching in the x direction, optional, default size
  22190. * * sizeY allows stretching in the y direction, optional, default size
  22191. * * sizeZ allows stretching in the z direction, optional, default size
  22192. * * 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
  22193. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22194. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22195. * * flat when true creates a flat shaded mesh, optional, default true
  22196. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22197. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22198. * * 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)
  22199. * * 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)
  22200. * @returns the VertexData of the Polyhedron
  22201. */
  22202. static CreatePolyhedron(options: {
  22203. type?: number;
  22204. size?: number;
  22205. sizeX?: number;
  22206. sizeY?: number;
  22207. sizeZ?: number;
  22208. custom?: any;
  22209. faceUV?: Vector4[];
  22210. faceColors?: Color4[];
  22211. flat?: boolean;
  22212. sideOrientation?: number;
  22213. frontUVs?: Vector4;
  22214. backUVs?: Vector4;
  22215. }): VertexData;
  22216. /**
  22217. * Creates the VertexData for a TorusKnot
  22218. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22219. * * radius the radius of the torus knot, optional, default 2
  22220. * * tube the thickness of the tube, optional, default 0.5
  22221. * * radialSegments the number of sides on each tube segments, optional, default 32
  22222. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22223. * * p the number of windings around the z axis, optional, default 2
  22224. * * q the number of windings around the x axis, optional, default 3
  22225. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22226. * * 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)
  22227. * * 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)
  22228. * @returns the VertexData of the Torus Knot
  22229. */
  22230. static CreateTorusKnot(options: {
  22231. radius?: number;
  22232. tube?: number;
  22233. radialSegments?: number;
  22234. tubularSegments?: number;
  22235. p?: number;
  22236. q?: number;
  22237. sideOrientation?: number;
  22238. frontUVs?: Vector4;
  22239. backUVs?: Vector4;
  22240. }): VertexData;
  22241. /**
  22242. * Compute normals for given positions and indices
  22243. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22244. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22245. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22246. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22247. * * facetNormals : optional array of facet normals (vector3)
  22248. * * facetPositions : optional array of facet positions (vector3)
  22249. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22250. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22251. * * bInfo : optional bounding info, required for facetPartitioning computation
  22252. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22253. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22254. * * useRightHandedSystem: optional boolean to for right handed system computation
  22255. * * depthSort : optional boolean to enable the facet depth sort computation
  22256. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22257. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22258. */
  22259. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22260. facetNormals?: any;
  22261. facetPositions?: any;
  22262. facetPartitioning?: any;
  22263. ratio?: number;
  22264. bInfo?: any;
  22265. bbSize?: Vector3;
  22266. subDiv?: any;
  22267. useRightHandedSystem?: boolean;
  22268. depthSort?: boolean;
  22269. distanceTo?: Vector3;
  22270. depthSortedFacets?: any;
  22271. }): void;
  22272. /** @hidden */
  22273. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22274. /**
  22275. * Applies VertexData created from the imported parameters to the geometry
  22276. * @param parsedVertexData the parsed data from an imported file
  22277. * @param geometry the geometry to apply the VertexData to
  22278. */
  22279. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22280. }
  22281. }
  22282. declare module BABYLON {
  22283. /**
  22284. * Defines a target to use with MorphTargetManager
  22285. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22286. */
  22287. export class MorphTarget implements IAnimatable {
  22288. /** defines the name of the target */
  22289. name: string;
  22290. /**
  22291. * Gets or sets the list of animations
  22292. */
  22293. animations: Animation[];
  22294. private _scene;
  22295. private _positions;
  22296. private _normals;
  22297. private _tangents;
  22298. private _uvs;
  22299. private _influence;
  22300. private _uniqueId;
  22301. /**
  22302. * Observable raised when the influence changes
  22303. */
  22304. onInfluenceChanged: Observable<boolean>;
  22305. /** @hidden */
  22306. _onDataLayoutChanged: Observable<void>;
  22307. /**
  22308. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22309. */
  22310. influence: number;
  22311. /**
  22312. * Gets or sets the id of the morph Target
  22313. */
  22314. id: string;
  22315. private _animationPropertiesOverride;
  22316. /**
  22317. * Gets or sets the animation properties override
  22318. */
  22319. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22320. /**
  22321. * Creates a new MorphTarget
  22322. * @param name defines the name of the target
  22323. * @param influence defines the influence to use
  22324. * @param scene defines the scene the morphtarget belongs to
  22325. */
  22326. constructor(
  22327. /** defines the name of the target */
  22328. name: string, influence?: number, scene?: Nullable<Scene>);
  22329. /**
  22330. * Gets the unique ID of this manager
  22331. */
  22332. readonly uniqueId: number;
  22333. /**
  22334. * Gets a boolean defining if the target contains position data
  22335. */
  22336. readonly hasPositions: boolean;
  22337. /**
  22338. * Gets a boolean defining if the target contains normal data
  22339. */
  22340. readonly hasNormals: boolean;
  22341. /**
  22342. * Gets a boolean defining if the target contains tangent data
  22343. */
  22344. readonly hasTangents: boolean;
  22345. /**
  22346. * Gets a boolean defining if the target contains texture coordinates data
  22347. */
  22348. readonly hasUVs: boolean;
  22349. /**
  22350. * Affects position data to this target
  22351. * @param data defines the position data to use
  22352. */
  22353. setPositions(data: Nullable<FloatArray>): void;
  22354. /**
  22355. * Gets the position data stored in this target
  22356. * @returns a FloatArray containing the position data (or null if not present)
  22357. */
  22358. getPositions(): Nullable<FloatArray>;
  22359. /**
  22360. * Affects normal data to this target
  22361. * @param data defines the normal data to use
  22362. */
  22363. setNormals(data: Nullable<FloatArray>): void;
  22364. /**
  22365. * Gets the normal data stored in this target
  22366. * @returns a FloatArray containing the normal data (or null if not present)
  22367. */
  22368. getNormals(): Nullable<FloatArray>;
  22369. /**
  22370. * Affects tangent data to this target
  22371. * @param data defines the tangent data to use
  22372. */
  22373. setTangents(data: Nullable<FloatArray>): void;
  22374. /**
  22375. * Gets the tangent data stored in this target
  22376. * @returns a FloatArray containing the tangent data (or null if not present)
  22377. */
  22378. getTangents(): Nullable<FloatArray>;
  22379. /**
  22380. * Affects texture coordinates data to this target
  22381. * @param data defines the texture coordinates data to use
  22382. */
  22383. setUVs(data: Nullable<FloatArray>): void;
  22384. /**
  22385. * Gets the texture coordinates data stored in this target
  22386. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22387. */
  22388. getUVs(): Nullable<FloatArray>;
  22389. /**
  22390. * Clone the current target
  22391. * @returns a new MorphTarget
  22392. */
  22393. clone(): MorphTarget;
  22394. /**
  22395. * Serializes the current target into a Serialization object
  22396. * @returns the serialized object
  22397. */
  22398. serialize(): any;
  22399. /**
  22400. * Returns the string "MorphTarget"
  22401. * @returns "MorphTarget"
  22402. */
  22403. getClassName(): string;
  22404. /**
  22405. * Creates a new target from serialized data
  22406. * @param serializationObject defines the serialized data to use
  22407. * @returns a new MorphTarget
  22408. */
  22409. static Parse(serializationObject: any): MorphTarget;
  22410. /**
  22411. * Creates a MorphTarget from mesh data
  22412. * @param mesh defines the source mesh
  22413. * @param name defines the name to use for the new target
  22414. * @param influence defines the influence to attach to the target
  22415. * @returns a new MorphTarget
  22416. */
  22417. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22418. }
  22419. }
  22420. declare module BABYLON {
  22421. /**
  22422. * This class is used to deform meshes using morphing between different targets
  22423. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22424. */
  22425. export class MorphTargetManager {
  22426. private _targets;
  22427. private _targetInfluenceChangedObservers;
  22428. private _targetDataLayoutChangedObservers;
  22429. private _activeTargets;
  22430. private _scene;
  22431. private _influences;
  22432. private _supportsNormals;
  22433. private _supportsTangents;
  22434. private _supportsUVs;
  22435. private _vertexCount;
  22436. private _uniqueId;
  22437. private _tempInfluences;
  22438. /**
  22439. * Gets or sets a boolean indicating if normals must be morphed
  22440. */
  22441. enableNormalMorphing: boolean;
  22442. /**
  22443. * Gets or sets a boolean indicating if tangents must be morphed
  22444. */
  22445. enableTangentMorphing: boolean;
  22446. /**
  22447. * Gets or sets a boolean indicating if UV must be morphed
  22448. */
  22449. enableUVMorphing: boolean;
  22450. /**
  22451. * Creates a new MorphTargetManager
  22452. * @param scene defines the current scene
  22453. */
  22454. constructor(scene?: Nullable<Scene>);
  22455. /**
  22456. * Gets the unique ID of this manager
  22457. */
  22458. readonly uniqueId: number;
  22459. /**
  22460. * Gets the number of vertices handled by this manager
  22461. */
  22462. readonly vertexCount: number;
  22463. /**
  22464. * Gets a boolean indicating if this manager supports morphing of normals
  22465. */
  22466. readonly supportsNormals: boolean;
  22467. /**
  22468. * Gets a boolean indicating if this manager supports morphing of tangents
  22469. */
  22470. readonly supportsTangents: boolean;
  22471. /**
  22472. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22473. */
  22474. readonly supportsUVs: boolean;
  22475. /**
  22476. * Gets the number of targets stored in this manager
  22477. */
  22478. readonly numTargets: number;
  22479. /**
  22480. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22481. */
  22482. readonly numInfluencers: number;
  22483. /**
  22484. * Gets the list of influences (one per target)
  22485. */
  22486. readonly influences: Float32Array;
  22487. /**
  22488. * Gets the active target at specified index. An active target is a target with an influence > 0
  22489. * @param index defines the index to check
  22490. * @returns the requested target
  22491. */
  22492. getActiveTarget(index: number): MorphTarget;
  22493. /**
  22494. * Gets the target at specified index
  22495. * @param index defines the index to check
  22496. * @returns the requested target
  22497. */
  22498. getTarget(index: number): MorphTarget;
  22499. /**
  22500. * Add a new target to this manager
  22501. * @param target defines the target to add
  22502. */
  22503. addTarget(target: MorphTarget): void;
  22504. /**
  22505. * Removes a target from the manager
  22506. * @param target defines the target to remove
  22507. */
  22508. removeTarget(target: MorphTarget): void;
  22509. /**
  22510. * Clone the current manager
  22511. * @returns a new MorphTargetManager
  22512. */
  22513. clone(): MorphTargetManager;
  22514. /**
  22515. * Serializes the current manager into a Serialization object
  22516. * @returns the serialized object
  22517. */
  22518. serialize(): any;
  22519. private _syncActiveTargets;
  22520. /**
  22521. * Syncrhonize the targets with all the meshes using this morph target manager
  22522. */
  22523. synchronize(): void;
  22524. /**
  22525. * Creates a new MorphTargetManager from serialized data
  22526. * @param serializationObject defines the serialized data
  22527. * @param scene defines the hosting scene
  22528. * @returns the new MorphTargetManager
  22529. */
  22530. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22531. }
  22532. }
  22533. declare module BABYLON {
  22534. /**
  22535. * Class used to represent a specific level of detail of a mesh
  22536. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22537. */
  22538. export class MeshLODLevel {
  22539. /** Defines the distance where this level should start being displayed */
  22540. distance: number;
  22541. /** Defines the mesh to use to render this level */
  22542. mesh: Nullable<Mesh>;
  22543. /**
  22544. * Creates a new LOD level
  22545. * @param distance defines the distance where this level should star being displayed
  22546. * @param mesh defines the mesh to use to render this level
  22547. */
  22548. constructor(
  22549. /** Defines the distance where this level should start being displayed */
  22550. distance: number,
  22551. /** Defines the mesh to use to render this level */
  22552. mesh: Nullable<Mesh>);
  22553. }
  22554. }
  22555. declare module BABYLON {
  22556. /**
  22557. * Mesh representing the gorund
  22558. */
  22559. export class GroundMesh extends Mesh {
  22560. /** If octree should be generated */
  22561. generateOctree: boolean;
  22562. private _heightQuads;
  22563. /** @hidden */
  22564. _subdivisionsX: number;
  22565. /** @hidden */
  22566. _subdivisionsY: number;
  22567. /** @hidden */
  22568. _width: number;
  22569. /** @hidden */
  22570. _height: number;
  22571. /** @hidden */
  22572. _minX: number;
  22573. /** @hidden */
  22574. _maxX: number;
  22575. /** @hidden */
  22576. _minZ: number;
  22577. /** @hidden */
  22578. _maxZ: number;
  22579. constructor(name: string, scene: Scene);
  22580. /**
  22581. * "GroundMesh"
  22582. * @returns "GroundMesh"
  22583. */
  22584. getClassName(): string;
  22585. /**
  22586. * The minimum of x and y subdivisions
  22587. */
  22588. readonly subdivisions: number;
  22589. /**
  22590. * X subdivisions
  22591. */
  22592. readonly subdivisionsX: number;
  22593. /**
  22594. * Y subdivisions
  22595. */
  22596. readonly subdivisionsY: number;
  22597. /**
  22598. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22599. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22600. * @param chunksCount the number of subdivisions for x and y
  22601. * @param octreeBlocksSize (Default: 32)
  22602. */
  22603. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22604. /**
  22605. * Returns a height (y) value in the Worl system :
  22606. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22607. * @param x x coordinate
  22608. * @param z z coordinate
  22609. * @returns the ground y position if (x, z) are outside the ground surface.
  22610. */
  22611. getHeightAtCoordinates(x: number, z: number): number;
  22612. /**
  22613. * Returns a normalized vector (Vector3) orthogonal to the ground
  22614. * at the ground coordinates (x, z) expressed in the World system.
  22615. * @param x x coordinate
  22616. * @param z z coordinate
  22617. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22618. */
  22619. getNormalAtCoordinates(x: number, z: number): Vector3;
  22620. /**
  22621. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22622. * at the ground coordinates (x, z) expressed in the World system.
  22623. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22624. * @param x x coordinate
  22625. * @param z z coordinate
  22626. * @param ref vector to store the result
  22627. * @returns the GroundMesh.
  22628. */
  22629. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22630. /**
  22631. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22632. * if the ground has been updated.
  22633. * This can be used in the render loop.
  22634. * @returns the GroundMesh.
  22635. */
  22636. updateCoordinateHeights(): GroundMesh;
  22637. private _getFacetAt;
  22638. private _initHeightQuads;
  22639. private _computeHeightQuads;
  22640. /**
  22641. * Serializes this ground mesh
  22642. * @param serializationObject object to write serialization to
  22643. */
  22644. serialize(serializationObject: any): void;
  22645. /**
  22646. * Parses a serialized ground mesh
  22647. * @param parsedMesh the serialized mesh
  22648. * @param scene the scene to create the ground mesh in
  22649. * @returns the created ground mesh
  22650. */
  22651. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22652. }
  22653. }
  22654. declare module BABYLON {
  22655. /**
  22656. * Interface for Physics-Joint data
  22657. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22658. */
  22659. export interface PhysicsJointData {
  22660. /**
  22661. * The main pivot of the joint
  22662. */
  22663. mainPivot?: Vector3;
  22664. /**
  22665. * The connected pivot of the joint
  22666. */
  22667. connectedPivot?: Vector3;
  22668. /**
  22669. * The main axis of the joint
  22670. */
  22671. mainAxis?: Vector3;
  22672. /**
  22673. * The connected axis of the joint
  22674. */
  22675. connectedAxis?: Vector3;
  22676. /**
  22677. * The collision of the joint
  22678. */
  22679. collision?: boolean;
  22680. /**
  22681. * Native Oimo/Cannon/Energy data
  22682. */
  22683. nativeParams?: any;
  22684. }
  22685. /**
  22686. * This is a holder class for the physics joint created by the physics plugin
  22687. * It holds a set of functions to control the underlying joint
  22688. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22689. */
  22690. export class PhysicsJoint {
  22691. /**
  22692. * The type of the physics joint
  22693. */
  22694. type: number;
  22695. /**
  22696. * The data for the physics joint
  22697. */
  22698. jointData: PhysicsJointData;
  22699. private _physicsJoint;
  22700. protected _physicsPlugin: IPhysicsEnginePlugin;
  22701. /**
  22702. * Initializes the physics joint
  22703. * @param type The type of the physics joint
  22704. * @param jointData The data for the physics joint
  22705. */
  22706. constructor(
  22707. /**
  22708. * The type of the physics joint
  22709. */
  22710. type: number,
  22711. /**
  22712. * The data for the physics joint
  22713. */
  22714. jointData: PhysicsJointData);
  22715. /**
  22716. * Gets the physics joint
  22717. */
  22718. /**
  22719. * Sets the physics joint
  22720. */
  22721. physicsJoint: any;
  22722. /**
  22723. * Sets the physics plugin
  22724. */
  22725. physicsPlugin: IPhysicsEnginePlugin;
  22726. /**
  22727. * Execute a function that is physics-plugin specific.
  22728. * @param {Function} func the function that will be executed.
  22729. * It accepts two parameters: the physics world and the physics joint
  22730. */
  22731. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22732. /**
  22733. * Distance-Joint type
  22734. */
  22735. static DistanceJoint: number;
  22736. /**
  22737. * Hinge-Joint type
  22738. */
  22739. static HingeJoint: number;
  22740. /**
  22741. * Ball-and-Socket joint type
  22742. */
  22743. static BallAndSocketJoint: number;
  22744. /**
  22745. * Wheel-Joint type
  22746. */
  22747. static WheelJoint: number;
  22748. /**
  22749. * Slider-Joint type
  22750. */
  22751. static SliderJoint: number;
  22752. /**
  22753. * Prismatic-Joint type
  22754. */
  22755. static PrismaticJoint: number;
  22756. /**
  22757. * Universal-Joint type
  22758. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22759. */
  22760. static UniversalJoint: number;
  22761. /**
  22762. * Hinge-Joint 2 type
  22763. */
  22764. static Hinge2Joint: number;
  22765. /**
  22766. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22767. */
  22768. static PointToPointJoint: number;
  22769. /**
  22770. * Spring-Joint type
  22771. */
  22772. static SpringJoint: number;
  22773. /**
  22774. * Lock-Joint type
  22775. */
  22776. static LockJoint: number;
  22777. }
  22778. /**
  22779. * A class representing a physics distance joint
  22780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22781. */
  22782. export class DistanceJoint extends PhysicsJoint {
  22783. /**
  22784. *
  22785. * @param jointData The data for the Distance-Joint
  22786. */
  22787. constructor(jointData: DistanceJointData);
  22788. /**
  22789. * Update the predefined distance.
  22790. * @param maxDistance The maximum preferred distance
  22791. * @param minDistance The minimum preferred distance
  22792. */
  22793. updateDistance(maxDistance: number, minDistance?: number): void;
  22794. }
  22795. /**
  22796. * Represents a Motor-Enabled Joint
  22797. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22798. */
  22799. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22800. /**
  22801. * Initializes the Motor-Enabled Joint
  22802. * @param type The type of the joint
  22803. * @param jointData The physica joint data for the joint
  22804. */
  22805. constructor(type: number, jointData: PhysicsJointData);
  22806. /**
  22807. * Set the motor values.
  22808. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22809. * @param force the force to apply
  22810. * @param maxForce max force for this motor.
  22811. */
  22812. setMotor(force?: number, maxForce?: number): void;
  22813. /**
  22814. * Set the motor's limits.
  22815. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22816. * @param upperLimit The upper limit of the motor
  22817. * @param lowerLimit The lower limit of the motor
  22818. */
  22819. setLimit(upperLimit: number, lowerLimit?: number): void;
  22820. }
  22821. /**
  22822. * This class represents a single physics Hinge-Joint
  22823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22824. */
  22825. export class HingeJoint extends MotorEnabledJoint {
  22826. /**
  22827. * Initializes the Hinge-Joint
  22828. * @param jointData The joint data for the Hinge-Joint
  22829. */
  22830. constructor(jointData: PhysicsJointData);
  22831. /**
  22832. * Set the motor values.
  22833. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22834. * @param {number} force the force to apply
  22835. * @param {number} maxForce max force for this motor.
  22836. */
  22837. setMotor(force?: number, maxForce?: number): void;
  22838. /**
  22839. * Set the motor's limits.
  22840. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22841. * @param upperLimit The upper limit of the motor
  22842. * @param lowerLimit The lower limit of the motor
  22843. */
  22844. setLimit(upperLimit: number, lowerLimit?: number): void;
  22845. }
  22846. /**
  22847. * This class represents a dual hinge physics joint (same as wheel joint)
  22848. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22849. */
  22850. export class Hinge2Joint extends MotorEnabledJoint {
  22851. /**
  22852. * Initializes the Hinge2-Joint
  22853. * @param jointData The joint data for the Hinge2-Joint
  22854. */
  22855. constructor(jointData: PhysicsJointData);
  22856. /**
  22857. * Set the motor values.
  22858. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22859. * @param {number} targetSpeed the speed the motor is to reach
  22860. * @param {number} maxForce max force for this motor.
  22861. * @param {motorIndex} the motor's index, 0 or 1.
  22862. */
  22863. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22864. /**
  22865. * Set the motor limits.
  22866. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22867. * @param {number} upperLimit the upper limit
  22868. * @param {number} lowerLimit lower limit
  22869. * @param {motorIndex} the motor's index, 0 or 1.
  22870. */
  22871. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22872. }
  22873. /**
  22874. * Interface for a motor enabled joint
  22875. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22876. */
  22877. export interface IMotorEnabledJoint {
  22878. /**
  22879. * Physics joint
  22880. */
  22881. physicsJoint: any;
  22882. /**
  22883. * Sets the motor of the motor-enabled joint
  22884. * @param force The force of the motor
  22885. * @param maxForce The maximum force of the motor
  22886. * @param motorIndex The index of the motor
  22887. */
  22888. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22889. /**
  22890. * Sets the limit of the motor
  22891. * @param upperLimit The upper limit of the motor
  22892. * @param lowerLimit The lower limit of the motor
  22893. * @param motorIndex The index of the motor
  22894. */
  22895. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22896. }
  22897. /**
  22898. * Joint data for a Distance-Joint
  22899. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22900. */
  22901. export interface DistanceJointData extends PhysicsJointData {
  22902. /**
  22903. * Max distance the 2 joint objects can be apart
  22904. */
  22905. maxDistance: number;
  22906. }
  22907. /**
  22908. * Joint data from a spring joint
  22909. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22910. */
  22911. export interface SpringJointData extends PhysicsJointData {
  22912. /**
  22913. * Length of the spring
  22914. */
  22915. length: number;
  22916. /**
  22917. * Stiffness of the spring
  22918. */
  22919. stiffness: number;
  22920. /**
  22921. * Damping of the spring
  22922. */
  22923. damping: number;
  22924. /** this callback will be called when applying the force to the impostors. */
  22925. forceApplicationCallback: () => void;
  22926. }
  22927. }
  22928. declare module BABYLON {
  22929. /**
  22930. * Holds the data for the raycast result
  22931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22932. */
  22933. export class PhysicsRaycastResult {
  22934. private _hasHit;
  22935. private _hitDistance;
  22936. private _hitNormalWorld;
  22937. private _hitPointWorld;
  22938. private _rayFromWorld;
  22939. private _rayToWorld;
  22940. /**
  22941. * Gets if there was a hit
  22942. */
  22943. readonly hasHit: boolean;
  22944. /**
  22945. * Gets the distance from the hit
  22946. */
  22947. readonly hitDistance: number;
  22948. /**
  22949. * Gets the hit normal/direction in the world
  22950. */
  22951. readonly hitNormalWorld: Vector3;
  22952. /**
  22953. * Gets the hit point in the world
  22954. */
  22955. readonly hitPointWorld: Vector3;
  22956. /**
  22957. * Gets the ray "start point" of the ray in the world
  22958. */
  22959. readonly rayFromWorld: Vector3;
  22960. /**
  22961. * Gets the ray "end point" of the ray in the world
  22962. */
  22963. readonly rayToWorld: Vector3;
  22964. /**
  22965. * Sets the hit data (normal & point in world space)
  22966. * @param hitNormalWorld defines the normal in world space
  22967. * @param hitPointWorld defines the point in world space
  22968. */
  22969. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22970. /**
  22971. * Sets the distance from the start point to the hit point
  22972. * @param distance
  22973. */
  22974. setHitDistance(distance: number): void;
  22975. /**
  22976. * Calculates the distance manually
  22977. */
  22978. calculateHitDistance(): void;
  22979. /**
  22980. * Resets all the values to default
  22981. * @param from The from point on world space
  22982. * @param to The to point on world space
  22983. */
  22984. reset(from?: Vector3, to?: Vector3): void;
  22985. }
  22986. /**
  22987. * Interface for the size containing width and height
  22988. */
  22989. interface IXYZ {
  22990. /**
  22991. * X
  22992. */
  22993. x: number;
  22994. /**
  22995. * Y
  22996. */
  22997. y: number;
  22998. /**
  22999. * Z
  23000. */
  23001. z: number;
  23002. }
  23003. }
  23004. declare module BABYLON {
  23005. /**
  23006. * Interface used to describe a physics joint
  23007. */
  23008. export interface PhysicsImpostorJoint {
  23009. /** Defines the main impostor to which the joint is linked */
  23010. mainImpostor: PhysicsImpostor;
  23011. /** Defines the impostor that is connected to the main impostor using this joint */
  23012. connectedImpostor: PhysicsImpostor;
  23013. /** Defines the joint itself */
  23014. joint: PhysicsJoint;
  23015. }
  23016. /** @hidden */
  23017. export interface IPhysicsEnginePlugin {
  23018. world: any;
  23019. name: string;
  23020. setGravity(gravity: Vector3): void;
  23021. setTimeStep(timeStep: number): void;
  23022. getTimeStep(): number;
  23023. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23024. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23025. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23026. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23027. removePhysicsBody(impostor: PhysicsImpostor): void;
  23028. generateJoint(joint: PhysicsImpostorJoint): void;
  23029. removeJoint(joint: PhysicsImpostorJoint): void;
  23030. isSupported(): boolean;
  23031. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23032. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23033. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23034. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23035. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23036. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23037. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23038. getBodyMass(impostor: PhysicsImpostor): number;
  23039. getBodyFriction(impostor: PhysicsImpostor): number;
  23040. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23041. getBodyRestitution(impostor: PhysicsImpostor): number;
  23042. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23043. getBodyPressure?(impostor: PhysicsImpostor): number;
  23044. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23045. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23046. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23047. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23048. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23049. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23050. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23051. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23052. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23053. sleepBody(impostor: PhysicsImpostor): void;
  23054. wakeUpBody(impostor: PhysicsImpostor): void;
  23055. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23056. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23057. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23058. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23059. getRadius(impostor: PhysicsImpostor): number;
  23060. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23061. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23062. dispose(): void;
  23063. }
  23064. /**
  23065. * Interface used to define a physics engine
  23066. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23067. */
  23068. export interface IPhysicsEngine {
  23069. /**
  23070. * Gets the gravity vector used by the simulation
  23071. */
  23072. gravity: Vector3;
  23073. /**
  23074. * Sets the gravity vector used by the simulation
  23075. * @param gravity defines the gravity vector to use
  23076. */
  23077. setGravity(gravity: Vector3): void;
  23078. /**
  23079. * Set the time step of the physics engine.
  23080. * Default is 1/60.
  23081. * To slow it down, enter 1/600 for example.
  23082. * To speed it up, 1/30
  23083. * @param newTimeStep the new timestep to apply to this world.
  23084. */
  23085. setTimeStep(newTimeStep: number): void;
  23086. /**
  23087. * Get the time step of the physics engine.
  23088. * @returns the current time step
  23089. */
  23090. getTimeStep(): number;
  23091. /**
  23092. * Set the sub time step of the physics engine.
  23093. * Default is 0 meaning there is no sub steps
  23094. * To increase physics resolution precision, set a small value (like 1 ms)
  23095. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23096. */
  23097. setSubTimeStep(subTimeStep: number): void;
  23098. /**
  23099. * Get the sub time step of the physics engine.
  23100. * @returns the current sub time step
  23101. */
  23102. getSubTimeStep(): number;
  23103. /**
  23104. * Release all resources
  23105. */
  23106. dispose(): void;
  23107. /**
  23108. * Gets the name of the current physics plugin
  23109. * @returns the name of the plugin
  23110. */
  23111. getPhysicsPluginName(): string;
  23112. /**
  23113. * Adding a new impostor for the impostor tracking.
  23114. * This will be done by the impostor itself.
  23115. * @param impostor the impostor to add
  23116. */
  23117. addImpostor(impostor: PhysicsImpostor): void;
  23118. /**
  23119. * Remove an impostor from the engine.
  23120. * This impostor and its mesh will not longer be updated by the physics engine.
  23121. * @param impostor the impostor to remove
  23122. */
  23123. removeImpostor(impostor: PhysicsImpostor): void;
  23124. /**
  23125. * Add a joint to the physics engine
  23126. * @param mainImpostor defines the main impostor to which the joint is added.
  23127. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23128. * @param joint defines the joint that will connect both impostors.
  23129. */
  23130. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23131. /**
  23132. * Removes a joint from the simulation
  23133. * @param mainImpostor defines the impostor used with the joint
  23134. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23135. * @param joint defines the joint to remove
  23136. */
  23137. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23138. /**
  23139. * Gets the current plugin used to run the simulation
  23140. * @returns current plugin
  23141. */
  23142. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23143. /**
  23144. * Gets the list of physic impostors
  23145. * @returns an array of PhysicsImpostor
  23146. */
  23147. getImpostors(): Array<PhysicsImpostor>;
  23148. /**
  23149. * Gets the impostor for a physics enabled object
  23150. * @param object defines the object impersonated by the impostor
  23151. * @returns the PhysicsImpostor or null if not found
  23152. */
  23153. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23154. /**
  23155. * Gets the impostor for a physics body object
  23156. * @param body defines physics body used by the impostor
  23157. * @returns the PhysicsImpostor or null if not found
  23158. */
  23159. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23160. /**
  23161. * Does a raycast in the physics world
  23162. * @param from when should the ray start?
  23163. * @param to when should the ray end?
  23164. * @returns PhysicsRaycastResult
  23165. */
  23166. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23167. /**
  23168. * Called by the scene. No need to call it.
  23169. * @param delta defines the timespam between frames
  23170. */
  23171. _step(delta: number): void;
  23172. }
  23173. }
  23174. declare module BABYLON {
  23175. /**
  23176. * The interface for the physics imposter parameters
  23177. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23178. */
  23179. export interface PhysicsImpostorParameters {
  23180. /**
  23181. * The mass of the physics imposter
  23182. */
  23183. mass: number;
  23184. /**
  23185. * The friction of the physics imposter
  23186. */
  23187. friction?: number;
  23188. /**
  23189. * The coefficient of restitution of the physics imposter
  23190. */
  23191. restitution?: number;
  23192. /**
  23193. * The native options of the physics imposter
  23194. */
  23195. nativeOptions?: any;
  23196. /**
  23197. * Specifies if the parent should be ignored
  23198. */
  23199. ignoreParent?: boolean;
  23200. /**
  23201. * Specifies if bi-directional transformations should be disabled
  23202. */
  23203. disableBidirectionalTransformation?: boolean;
  23204. /**
  23205. * The pressure inside the physics imposter, soft object only
  23206. */
  23207. pressure?: number;
  23208. /**
  23209. * The stiffness the physics imposter, soft object only
  23210. */
  23211. stiffness?: number;
  23212. /**
  23213. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23214. */
  23215. velocityIterations?: number;
  23216. /**
  23217. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23218. */
  23219. positionIterations?: number;
  23220. /**
  23221. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23222. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23223. * Add to fix multiple points
  23224. */
  23225. fixedPoints?: number;
  23226. /**
  23227. * The collision margin around a soft object
  23228. */
  23229. margin?: number;
  23230. /**
  23231. * The collision margin around a soft object
  23232. */
  23233. damping?: number;
  23234. /**
  23235. * The path for a rope based on an extrusion
  23236. */
  23237. path?: any;
  23238. /**
  23239. * The shape of an extrusion used for a rope based on an extrusion
  23240. */
  23241. shape?: any;
  23242. }
  23243. /**
  23244. * Interface for a physics-enabled object
  23245. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23246. */
  23247. export interface IPhysicsEnabledObject {
  23248. /**
  23249. * The position of the physics-enabled object
  23250. */
  23251. position: Vector3;
  23252. /**
  23253. * The rotation of the physics-enabled object
  23254. */
  23255. rotationQuaternion: Nullable<Quaternion>;
  23256. /**
  23257. * The scale of the physics-enabled object
  23258. */
  23259. scaling: Vector3;
  23260. /**
  23261. * The rotation of the physics-enabled object
  23262. */
  23263. rotation?: Vector3;
  23264. /**
  23265. * The parent of the physics-enabled object
  23266. */
  23267. parent?: any;
  23268. /**
  23269. * The bounding info of the physics-enabled object
  23270. * @returns The bounding info of the physics-enabled object
  23271. */
  23272. getBoundingInfo(): BoundingInfo;
  23273. /**
  23274. * Computes the world matrix
  23275. * @param force Specifies if the world matrix should be computed by force
  23276. * @returns A world matrix
  23277. */
  23278. computeWorldMatrix(force: boolean): Matrix;
  23279. /**
  23280. * Gets the world matrix
  23281. * @returns A world matrix
  23282. */
  23283. getWorldMatrix?(): Matrix;
  23284. /**
  23285. * Gets the child meshes
  23286. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23287. * @returns An array of abstract meshes
  23288. */
  23289. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23290. /**
  23291. * Gets the vertex data
  23292. * @param kind The type of vertex data
  23293. * @returns A nullable array of numbers, or a float32 array
  23294. */
  23295. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23296. /**
  23297. * Gets the indices from the mesh
  23298. * @returns A nullable array of index arrays
  23299. */
  23300. getIndices?(): Nullable<IndicesArray>;
  23301. /**
  23302. * Gets the scene from the mesh
  23303. * @returns the indices array or null
  23304. */
  23305. getScene?(): Scene;
  23306. /**
  23307. * Gets the absolute position from the mesh
  23308. * @returns the absolute position
  23309. */
  23310. getAbsolutePosition(): Vector3;
  23311. /**
  23312. * Gets the absolute pivot point from the mesh
  23313. * @returns the absolute pivot point
  23314. */
  23315. getAbsolutePivotPoint(): Vector3;
  23316. /**
  23317. * Rotates the mesh
  23318. * @param axis The axis of rotation
  23319. * @param amount The amount of rotation
  23320. * @param space The space of the rotation
  23321. * @returns The rotation transform node
  23322. */
  23323. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23324. /**
  23325. * Translates the mesh
  23326. * @param axis The axis of translation
  23327. * @param distance The distance of translation
  23328. * @param space The space of the translation
  23329. * @returns The transform node
  23330. */
  23331. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23332. /**
  23333. * Sets the absolute position of the mesh
  23334. * @param absolutePosition The absolute position of the mesh
  23335. * @returns The transform node
  23336. */
  23337. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23338. /**
  23339. * Gets the class name of the mesh
  23340. * @returns The class name
  23341. */
  23342. getClassName(): string;
  23343. }
  23344. /**
  23345. * Represents a physics imposter
  23346. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23347. */
  23348. export class PhysicsImpostor {
  23349. /**
  23350. * The physics-enabled object used as the physics imposter
  23351. */
  23352. object: IPhysicsEnabledObject;
  23353. /**
  23354. * The type of the physics imposter
  23355. */
  23356. type: number;
  23357. private _options;
  23358. private _scene?;
  23359. /**
  23360. * The default object size of the imposter
  23361. */
  23362. static DEFAULT_OBJECT_SIZE: Vector3;
  23363. /**
  23364. * The identity quaternion of the imposter
  23365. */
  23366. static IDENTITY_QUATERNION: Quaternion;
  23367. /** @hidden */
  23368. _pluginData: any;
  23369. private _physicsEngine;
  23370. private _physicsBody;
  23371. private _bodyUpdateRequired;
  23372. private _onBeforePhysicsStepCallbacks;
  23373. private _onAfterPhysicsStepCallbacks;
  23374. /** @hidden */
  23375. _onPhysicsCollideCallbacks: Array<{
  23376. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23377. otherImpostors: Array<PhysicsImpostor>;
  23378. }>;
  23379. private _deltaPosition;
  23380. private _deltaRotation;
  23381. private _deltaRotationConjugated;
  23382. /** @hidden */
  23383. _isFromLine: boolean;
  23384. private _parent;
  23385. private _isDisposed;
  23386. private static _tmpVecs;
  23387. private static _tmpQuat;
  23388. /**
  23389. * Specifies if the physics imposter is disposed
  23390. */
  23391. readonly isDisposed: boolean;
  23392. /**
  23393. * Gets the mass of the physics imposter
  23394. */
  23395. mass: number;
  23396. /**
  23397. * Gets the coefficient of friction
  23398. */
  23399. /**
  23400. * Sets the coefficient of friction
  23401. */
  23402. friction: number;
  23403. /**
  23404. * Gets the coefficient of restitution
  23405. */
  23406. /**
  23407. * Sets the coefficient of restitution
  23408. */
  23409. restitution: number;
  23410. /**
  23411. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23412. */
  23413. /**
  23414. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23415. */
  23416. pressure: number;
  23417. /**
  23418. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23419. */
  23420. /**
  23421. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23422. */
  23423. stiffness: number;
  23424. /**
  23425. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23426. */
  23427. /**
  23428. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23429. */
  23430. velocityIterations: number;
  23431. /**
  23432. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23433. */
  23434. /**
  23435. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23436. */
  23437. positionIterations: number;
  23438. /**
  23439. * The unique id of the physics imposter
  23440. * set by the physics engine when adding this impostor to the array
  23441. */
  23442. uniqueId: number;
  23443. /**
  23444. * @hidden
  23445. */
  23446. soft: boolean;
  23447. /**
  23448. * @hidden
  23449. */
  23450. segments: number;
  23451. private _joints;
  23452. /**
  23453. * Initializes the physics imposter
  23454. * @param object The physics-enabled object used as the physics imposter
  23455. * @param type The type of the physics imposter
  23456. * @param _options The options for the physics imposter
  23457. * @param _scene The Babylon scene
  23458. */
  23459. constructor(
  23460. /**
  23461. * The physics-enabled object used as the physics imposter
  23462. */
  23463. object: IPhysicsEnabledObject,
  23464. /**
  23465. * The type of the physics imposter
  23466. */
  23467. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23468. /**
  23469. * This function will completly initialize this impostor.
  23470. * It will create a new body - but only if this mesh has no parent.
  23471. * If it has, this impostor will not be used other than to define the impostor
  23472. * of the child mesh.
  23473. * @hidden
  23474. */
  23475. _init(): void;
  23476. private _getPhysicsParent;
  23477. /**
  23478. * Should a new body be generated.
  23479. * @returns boolean specifying if body initialization is required
  23480. */
  23481. isBodyInitRequired(): boolean;
  23482. /**
  23483. * Sets the updated scaling
  23484. * @param updated Specifies if the scaling is updated
  23485. */
  23486. setScalingUpdated(): void;
  23487. /**
  23488. * Force a regeneration of this or the parent's impostor's body.
  23489. * Use under cautious - This will remove all joints already implemented.
  23490. */
  23491. forceUpdate(): void;
  23492. /**
  23493. * Gets the body that holds this impostor. Either its own, or its parent.
  23494. */
  23495. /**
  23496. * Set the physics body. Used mainly by the physics engine/plugin
  23497. */
  23498. physicsBody: any;
  23499. /**
  23500. * Get the parent of the physics imposter
  23501. * @returns Physics imposter or null
  23502. */
  23503. /**
  23504. * Sets the parent of the physics imposter
  23505. */
  23506. parent: Nullable<PhysicsImpostor>;
  23507. /**
  23508. * Resets the update flags
  23509. */
  23510. resetUpdateFlags(): void;
  23511. /**
  23512. * Gets the object extend size
  23513. * @returns the object extend size
  23514. */
  23515. getObjectExtendSize(): Vector3;
  23516. /**
  23517. * Gets the object center
  23518. * @returns The object center
  23519. */
  23520. getObjectCenter(): Vector3;
  23521. /**
  23522. * Get a specific parametes from the options parameter
  23523. * @param paramName The object parameter name
  23524. * @returns The object parameter
  23525. */
  23526. getParam(paramName: string): any;
  23527. /**
  23528. * Sets a specific parameter in the options given to the physics plugin
  23529. * @param paramName The parameter name
  23530. * @param value The value of the parameter
  23531. */
  23532. setParam(paramName: string, value: number): void;
  23533. /**
  23534. * Specifically change the body's mass option. Won't recreate the physics body object
  23535. * @param mass The mass of the physics imposter
  23536. */
  23537. setMass(mass: number): void;
  23538. /**
  23539. * Gets the linear velocity
  23540. * @returns linear velocity or null
  23541. */
  23542. getLinearVelocity(): Nullable<Vector3>;
  23543. /**
  23544. * Sets the linear velocity
  23545. * @param velocity linear velocity or null
  23546. */
  23547. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23548. /**
  23549. * Gets the angular velocity
  23550. * @returns angular velocity or null
  23551. */
  23552. getAngularVelocity(): Nullable<Vector3>;
  23553. /**
  23554. * Sets the angular velocity
  23555. * @param velocity The velocity or null
  23556. */
  23557. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23558. /**
  23559. * Execute a function with the physics plugin native code
  23560. * Provide a function the will have two variables - the world object and the physics body object
  23561. * @param func The function to execute with the physics plugin native code
  23562. */
  23563. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23564. /**
  23565. * Register a function that will be executed before the physics world is stepping forward
  23566. * @param func The function to execute before the physics world is stepped forward
  23567. */
  23568. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23569. /**
  23570. * Unregister a function that will be executed before the physics world is stepping forward
  23571. * @param func The function to execute before the physics world is stepped forward
  23572. */
  23573. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23574. /**
  23575. * Register a function that will be executed after the physics step
  23576. * @param func The function to execute after physics step
  23577. */
  23578. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23579. /**
  23580. * Unregisters a function that will be executed after the physics step
  23581. * @param func The function to execute after physics step
  23582. */
  23583. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23584. /**
  23585. * register a function that will be executed when this impostor collides against a different body
  23586. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23587. * @param func Callback that is executed on collision
  23588. */
  23589. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23590. /**
  23591. * Unregisters the physics imposter on contact
  23592. * @param collideAgainst The physics object to collide against
  23593. * @param func Callback to execute on collision
  23594. */
  23595. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23596. private _tmpQuat;
  23597. private _tmpQuat2;
  23598. /**
  23599. * Get the parent rotation
  23600. * @returns The parent rotation
  23601. */
  23602. getParentsRotation(): Quaternion;
  23603. /**
  23604. * this function is executed by the physics engine.
  23605. */
  23606. beforeStep: () => void;
  23607. /**
  23608. * this function is executed by the physics engine
  23609. */
  23610. afterStep: () => void;
  23611. /**
  23612. * Legacy collision detection event support
  23613. */
  23614. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23615. /**
  23616. * event and body object due to cannon's event-based architecture.
  23617. */
  23618. onCollide: (e: {
  23619. body: any;
  23620. }) => void;
  23621. /**
  23622. * Apply a force
  23623. * @param force The force to apply
  23624. * @param contactPoint The contact point for the force
  23625. * @returns The physics imposter
  23626. */
  23627. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23628. /**
  23629. * Apply an impulse
  23630. * @param force The impulse force
  23631. * @param contactPoint The contact point for the impulse force
  23632. * @returns The physics imposter
  23633. */
  23634. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23635. /**
  23636. * A help function to create a joint
  23637. * @param otherImpostor A physics imposter used to create a joint
  23638. * @param jointType The type of joint
  23639. * @param jointData The data for the joint
  23640. * @returns The physics imposter
  23641. */
  23642. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23643. /**
  23644. * Add a joint to this impostor with a different impostor
  23645. * @param otherImpostor A physics imposter used to add a joint
  23646. * @param joint The joint to add
  23647. * @returns The physics imposter
  23648. */
  23649. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23650. /**
  23651. * Add an anchor to a cloth impostor
  23652. * @param otherImpostor rigid impostor to anchor to
  23653. * @param width ratio across width from 0 to 1
  23654. * @param height ratio up height from 0 to 1
  23655. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23656. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23657. * @returns impostor the soft imposter
  23658. */
  23659. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23660. /**
  23661. * Add a hook to a rope impostor
  23662. * @param otherImpostor rigid impostor to anchor to
  23663. * @param length ratio across rope from 0 to 1
  23664. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23665. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23666. * @returns impostor the rope imposter
  23667. */
  23668. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23669. /**
  23670. * Will keep this body still, in a sleep mode.
  23671. * @returns the physics imposter
  23672. */
  23673. sleep(): PhysicsImpostor;
  23674. /**
  23675. * Wake the body up.
  23676. * @returns The physics imposter
  23677. */
  23678. wakeUp(): PhysicsImpostor;
  23679. /**
  23680. * Clones the physics imposter
  23681. * @param newObject The physics imposter clones to this physics-enabled object
  23682. * @returns A nullable physics imposter
  23683. */
  23684. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23685. /**
  23686. * Disposes the physics imposter
  23687. */
  23688. dispose(): void;
  23689. /**
  23690. * Sets the delta position
  23691. * @param position The delta position amount
  23692. */
  23693. setDeltaPosition(position: Vector3): void;
  23694. /**
  23695. * Sets the delta rotation
  23696. * @param rotation The delta rotation amount
  23697. */
  23698. setDeltaRotation(rotation: Quaternion): void;
  23699. /**
  23700. * Gets the box size of the physics imposter and stores the result in the input parameter
  23701. * @param result Stores the box size
  23702. * @returns The physics imposter
  23703. */
  23704. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23705. /**
  23706. * Gets the radius of the physics imposter
  23707. * @returns Radius of the physics imposter
  23708. */
  23709. getRadius(): number;
  23710. /**
  23711. * Sync a bone with this impostor
  23712. * @param bone The bone to sync to the impostor.
  23713. * @param boneMesh The mesh that the bone is influencing.
  23714. * @param jointPivot The pivot of the joint / bone in local space.
  23715. * @param distToJoint Optional distance from the impostor to the joint.
  23716. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23717. */
  23718. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23719. /**
  23720. * Sync impostor to a bone
  23721. * @param bone The bone that the impostor will be synced to.
  23722. * @param boneMesh The mesh that the bone is influencing.
  23723. * @param jointPivot The pivot of the joint / bone in local space.
  23724. * @param distToJoint Optional distance from the impostor to the joint.
  23725. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23726. * @param boneAxis Optional vector3 axis the bone is aligned with
  23727. */
  23728. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23729. /**
  23730. * No-Imposter type
  23731. */
  23732. static NoImpostor: number;
  23733. /**
  23734. * Sphere-Imposter type
  23735. */
  23736. static SphereImpostor: number;
  23737. /**
  23738. * Box-Imposter type
  23739. */
  23740. static BoxImpostor: number;
  23741. /**
  23742. * Plane-Imposter type
  23743. */
  23744. static PlaneImpostor: number;
  23745. /**
  23746. * Mesh-imposter type
  23747. */
  23748. static MeshImpostor: number;
  23749. /**
  23750. * Capsule-Impostor type (Ammo.js plugin only)
  23751. */
  23752. static CapsuleImpostor: number;
  23753. /**
  23754. * Cylinder-Imposter type
  23755. */
  23756. static CylinderImpostor: number;
  23757. /**
  23758. * Particle-Imposter type
  23759. */
  23760. static ParticleImpostor: number;
  23761. /**
  23762. * Heightmap-Imposter type
  23763. */
  23764. static HeightmapImpostor: number;
  23765. /**
  23766. * ConvexHull-Impostor type (Ammo.js plugin only)
  23767. */
  23768. static ConvexHullImpostor: number;
  23769. /**
  23770. * Custom-Imposter type (Ammo.js plugin only)
  23771. */
  23772. static CustomImpostor: number;
  23773. /**
  23774. * Rope-Imposter type
  23775. */
  23776. static RopeImpostor: number;
  23777. /**
  23778. * Cloth-Imposter type
  23779. */
  23780. static ClothImpostor: number;
  23781. /**
  23782. * Softbody-Imposter type
  23783. */
  23784. static SoftbodyImpostor: number;
  23785. }
  23786. }
  23787. declare module BABYLON {
  23788. /**
  23789. * @hidden
  23790. **/
  23791. export class _CreationDataStorage {
  23792. closePath?: boolean;
  23793. closeArray?: boolean;
  23794. idx: number[];
  23795. dashSize: number;
  23796. gapSize: number;
  23797. path3D: Path3D;
  23798. pathArray: Vector3[][];
  23799. arc: number;
  23800. radius: number;
  23801. cap: number;
  23802. tessellation: number;
  23803. }
  23804. /**
  23805. * @hidden
  23806. **/
  23807. class _InstanceDataStorage {
  23808. visibleInstances: any;
  23809. batchCache: _InstancesBatch;
  23810. instancesBufferSize: number;
  23811. instancesBuffer: Nullable<Buffer>;
  23812. instancesData: Float32Array;
  23813. overridenInstanceCount: number;
  23814. isFrozen: boolean;
  23815. previousBatch: Nullable<_InstancesBatch>;
  23816. hardwareInstancedRendering: boolean;
  23817. sideOrientation: number;
  23818. manualUpdate: boolean;
  23819. }
  23820. /**
  23821. * @hidden
  23822. **/
  23823. export class _InstancesBatch {
  23824. mustReturn: boolean;
  23825. visibleInstances: Nullable<InstancedMesh[]>[];
  23826. renderSelf: boolean[];
  23827. hardwareInstancedRendering: boolean[];
  23828. }
  23829. /**
  23830. * Class used to represent renderable models
  23831. */
  23832. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23833. /**
  23834. * Mesh side orientation : usually the external or front surface
  23835. */
  23836. static readonly FRONTSIDE: number;
  23837. /**
  23838. * Mesh side orientation : usually the internal or back surface
  23839. */
  23840. static readonly BACKSIDE: number;
  23841. /**
  23842. * Mesh side orientation : both internal and external or front and back surfaces
  23843. */
  23844. static readonly DOUBLESIDE: number;
  23845. /**
  23846. * Mesh side orientation : by default, `FRONTSIDE`
  23847. */
  23848. static readonly DEFAULTSIDE: number;
  23849. /**
  23850. * Mesh cap setting : no cap
  23851. */
  23852. static readonly NO_CAP: number;
  23853. /**
  23854. * Mesh cap setting : one cap at the beginning of the mesh
  23855. */
  23856. static readonly CAP_START: number;
  23857. /**
  23858. * Mesh cap setting : one cap at the end of the mesh
  23859. */
  23860. static readonly CAP_END: number;
  23861. /**
  23862. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23863. */
  23864. static readonly CAP_ALL: number;
  23865. /**
  23866. * Mesh pattern setting : no flip or rotate
  23867. */
  23868. static readonly NO_FLIP: number;
  23869. /**
  23870. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23871. */
  23872. static readonly FLIP_TILE: number;
  23873. /**
  23874. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23875. */
  23876. static readonly ROTATE_TILE: number;
  23877. /**
  23878. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23879. */
  23880. static readonly FLIP_ROW: number;
  23881. /**
  23882. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23883. */
  23884. static readonly ROTATE_ROW: number;
  23885. /**
  23886. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23887. */
  23888. static readonly FLIP_N_ROTATE_TILE: number;
  23889. /**
  23890. * Mesh pattern setting : rotate pattern and rotate
  23891. */
  23892. static readonly FLIP_N_ROTATE_ROW: number;
  23893. /**
  23894. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23895. */
  23896. static readonly CENTER: number;
  23897. /**
  23898. * Mesh tile positioning : part tiles on left
  23899. */
  23900. static readonly LEFT: number;
  23901. /**
  23902. * Mesh tile positioning : part tiles on right
  23903. */
  23904. static readonly RIGHT: number;
  23905. /**
  23906. * Mesh tile positioning : part tiles on top
  23907. */
  23908. static readonly TOP: number;
  23909. /**
  23910. * Mesh tile positioning : part tiles on bottom
  23911. */
  23912. static readonly BOTTOM: number;
  23913. /**
  23914. * Gets the default side orientation.
  23915. * @param orientation the orientation to value to attempt to get
  23916. * @returns the default orientation
  23917. * @hidden
  23918. */
  23919. static _GetDefaultSideOrientation(orientation?: number): number;
  23920. private _internalMeshDataInfo;
  23921. /**
  23922. * An event triggered before rendering the mesh
  23923. */
  23924. readonly onBeforeRenderObservable: Observable<Mesh>;
  23925. /**
  23926. * An event triggered before binding the mesh
  23927. */
  23928. readonly onBeforeBindObservable: Observable<Mesh>;
  23929. /**
  23930. * An event triggered after rendering the mesh
  23931. */
  23932. readonly onAfterRenderObservable: Observable<Mesh>;
  23933. /**
  23934. * An event triggered before drawing the mesh
  23935. */
  23936. readonly onBeforeDrawObservable: Observable<Mesh>;
  23937. private _onBeforeDrawObserver;
  23938. /**
  23939. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23940. */
  23941. onBeforeDraw: () => void;
  23942. readonly hasInstances: boolean;
  23943. /**
  23944. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23945. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23946. */
  23947. delayLoadState: number;
  23948. /**
  23949. * Gets the list of instances created from this mesh
  23950. * it is not supposed to be modified manually.
  23951. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23952. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23953. */
  23954. instances: InstancedMesh[];
  23955. /**
  23956. * Gets the file containing delay loading data for this mesh
  23957. */
  23958. delayLoadingFile: string;
  23959. /** @hidden */
  23960. _binaryInfo: any;
  23961. /**
  23962. * User defined function used to change how LOD level selection is done
  23963. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23964. */
  23965. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23966. /**
  23967. * Gets or sets the morph target manager
  23968. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23969. */
  23970. morphTargetManager: Nullable<MorphTargetManager>;
  23971. /** @hidden */
  23972. _creationDataStorage: Nullable<_CreationDataStorage>;
  23973. /** @hidden */
  23974. _geometry: Nullable<Geometry>;
  23975. /** @hidden */
  23976. _delayInfo: Array<string>;
  23977. /** @hidden */
  23978. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23979. /** @hidden */
  23980. _instanceDataStorage: _InstanceDataStorage;
  23981. private _effectiveMaterial;
  23982. /** @hidden */
  23983. _shouldGenerateFlatShading: boolean;
  23984. /** @hidden */
  23985. _originalBuilderSideOrientation: number;
  23986. /**
  23987. * Use this property to change the original side orientation defined at construction time
  23988. */
  23989. overrideMaterialSideOrientation: Nullable<number>;
  23990. /**
  23991. * Gets the source mesh (the one used to clone this one from)
  23992. */
  23993. readonly source: Nullable<Mesh>;
  23994. /**
  23995. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23996. */
  23997. isUnIndexed: boolean;
  23998. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  23999. readonly worldMatrixInstancedBuffer: Float32Array;
  24000. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24001. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  24002. /**
  24003. * @constructor
  24004. * @param name The value used by scene.getMeshByName() to do a lookup.
  24005. * @param scene The scene to add this mesh to.
  24006. * @param parent The parent of this mesh, if it has one
  24007. * @param source An optional Mesh from which geometry is shared, cloned.
  24008. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24009. * When false, achieved by calling a clone(), also passing False.
  24010. * This will make creation of children, recursive.
  24011. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24012. */
  24013. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24014. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24015. doNotInstantiate: boolean;
  24016. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24017. /**
  24018. * Gets the class name
  24019. * @returns the string "Mesh".
  24020. */
  24021. getClassName(): string;
  24022. /** @hidden */
  24023. readonly _isMesh: boolean;
  24024. /**
  24025. * Returns a description of this mesh
  24026. * @param fullDetails define if full details about this mesh must be used
  24027. * @returns a descriptive string representing this mesh
  24028. */
  24029. toString(fullDetails?: boolean): string;
  24030. /** @hidden */
  24031. _unBindEffect(): void;
  24032. /**
  24033. * Gets a boolean indicating if this mesh has LOD
  24034. */
  24035. readonly hasLODLevels: boolean;
  24036. /**
  24037. * Gets the list of MeshLODLevel associated with the current mesh
  24038. * @returns an array of MeshLODLevel
  24039. */
  24040. getLODLevels(): MeshLODLevel[];
  24041. private _sortLODLevels;
  24042. /**
  24043. * Add a mesh as LOD level triggered at the given distance.
  24044. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24045. * @param distance The distance from the center of the object to show this level
  24046. * @param mesh The mesh to be added as LOD level (can be null)
  24047. * @return This mesh (for chaining)
  24048. */
  24049. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24050. /**
  24051. * Returns the LOD level mesh at the passed distance or null if not found.
  24052. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24053. * @param distance The distance from the center of the object to show this level
  24054. * @returns a Mesh or `null`
  24055. */
  24056. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24057. /**
  24058. * Remove a mesh from the LOD array
  24059. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24060. * @param mesh defines the mesh to be removed
  24061. * @return This mesh (for chaining)
  24062. */
  24063. removeLODLevel(mesh: Mesh): Mesh;
  24064. /**
  24065. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24066. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24067. * @param camera defines the camera to use to compute distance
  24068. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24069. * @return This mesh (for chaining)
  24070. */
  24071. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24072. /**
  24073. * Gets the mesh internal Geometry object
  24074. */
  24075. readonly geometry: Nullable<Geometry>;
  24076. /**
  24077. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24078. * @returns the total number of vertices
  24079. */
  24080. getTotalVertices(): number;
  24081. /**
  24082. * Returns the content of an associated vertex buffer
  24083. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24084. * - VertexBuffer.PositionKind
  24085. * - VertexBuffer.UVKind
  24086. * - VertexBuffer.UV2Kind
  24087. * - VertexBuffer.UV3Kind
  24088. * - VertexBuffer.UV4Kind
  24089. * - VertexBuffer.UV5Kind
  24090. * - VertexBuffer.UV6Kind
  24091. * - VertexBuffer.ColorKind
  24092. * - VertexBuffer.MatricesIndicesKind
  24093. * - VertexBuffer.MatricesIndicesExtraKind
  24094. * - VertexBuffer.MatricesWeightsKind
  24095. * - VertexBuffer.MatricesWeightsExtraKind
  24096. * @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
  24097. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24098. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24099. */
  24100. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24101. /**
  24102. * Returns the mesh VertexBuffer object from the requested `kind`
  24103. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24104. * - VertexBuffer.PositionKind
  24105. * - VertexBuffer.NormalKind
  24106. * - VertexBuffer.UVKind
  24107. * - VertexBuffer.UV2Kind
  24108. * - VertexBuffer.UV3Kind
  24109. * - VertexBuffer.UV4Kind
  24110. * - VertexBuffer.UV5Kind
  24111. * - VertexBuffer.UV6Kind
  24112. * - VertexBuffer.ColorKind
  24113. * - VertexBuffer.MatricesIndicesKind
  24114. * - VertexBuffer.MatricesIndicesExtraKind
  24115. * - VertexBuffer.MatricesWeightsKind
  24116. * - VertexBuffer.MatricesWeightsExtraKind
  24117. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24118. */
  24119. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24120. /**
  24121. * Tests if a specific vertex buffer is associated with this mesh
  24122. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24123. * - VertexBuffer.PositionKind
  24124. * - VertexBuffer.NormalKind
  24125. * - VertexBuffer.UVKind
  24126. * - VertexBuffer.UV2Kind
  24127. * - VertexBuffer.UV3Kind
  24128. * - VertexBuffer.UV4Kind
  24129. * - VertexBuffer.UV5Kind
  24130. * - VertexBuffer.UV6Kind
  24131. * - VertexBuffer.ColorKind
  24132. * - VertexBuffer.MatricesIndicesKind
  24133. * - VertexBuffer.MatricesIndicesExtraKind
  24134. * - VertexBuffer.MatricesWeightsKind
  24135. * - VertexBuffer.MatricesWeightsExtraKind
  24136. * @returns a boolean
  24137. */
  24138. isVerticesDataPresent(kind: string): boolean;
  24139. /**
  24140. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24141. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24142. * - VertexBuffer.PositionKind
  24143. * - VertexBuffer.UVKind
  24144. * - VertexBuffer.UV2Kind
  24145. * - VertexBuffer.UV3Kind
  24146. * - VertexBuffer.UV4Kind
  24147. * - VertexBuffer.UV5Kind
  24148. * - VertexBuffer.UV6Kind
  24149. * - VertexBuffer.ColorKind
  24150. * - VertexBuffer.MatricesIndicesKind
  24151. * - VertexBuffer.MatricesIndicesExtraKind
  24152. * - VertexBuffer.MatricesWeightsKind
  24153. * - VertexBuffer.MatricesWeightsExtraKind
  24154. * @returns a boolean
  24155. */
  24156. isVertexBufferUpdatable(kind: string): boolean;
  24157. /**
  24158. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24159. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24160. * - VertexBuffer.PositionKind
  24161. * - VertexBuffer.NormalKind
  24162. * - VertexBuffer.UVKind
  24163. * - VertexBuffer.UV2Kind
  24164. * - VertexBuffer.UV3Kind
  24165. * - VertexBuffer.UV4Kind
  24166. * - VertexBuffer.UV5Kind
  24167. * - VertexBuffer.UV6Kind
  24168. * - VertexBuffer.ColorKind
  24169. * - VertexBuffer.MatricesIndicesKind
  24170. * - VertexBuffer.MatricesIndicesExtraKind
  24171. * - VertexBuffer.MatricesWeightsKind
  24172. * - VertexBuffer.MatricesWeightsExtraKind
  24173. * @returns an array of strings
  24174. */
  24175. getVerticesDataKinds(): string[];
  24176. /**
  24177. * Returns a positive integer : the total number of indices in this mesh geometry.
  24178. * @returns the numner of indices or zero if the mesh has no geometry.
  24179. */
  24180. getTotalIndices(): number;
  24181. /**
  24182. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24183. * @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.
  24184. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24185. * @returns the indices array or an empty array if the mesh has no geometry
  24186. */
  24187. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24188. readonly isBlocked: boolean;
  24189. /**
  24190. * Determine if the current mesh is ready to be rendered
  24191. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24192. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24193. * @returns true if all associated assets are ready (material, textures, shaders)
  24194. */
  24195. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24196. /**
  24197. * 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.
  24198. */
  24199. readonly areNormalsFrozen: boolean;
  24200. /**
  24201. * 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.
  24202. * @returns the current mesh
  24203. */
  24204. freezeNormals(): Mesh;
  24205. /**
  24206. * 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
  24207. * @returns the current mesh
  24208. */
  24209. unfreezeNormals(): Mesh;
  24210. /**
  24211. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24212. */
  24213. overridenInstanceCount: number;
  24214. /** @hidden */
  24215. _preActivate(): Mesh;
  24216. /** @hidden */
  24217. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24218. /** @hidden */
  24219. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24220. /**
  24221. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24222. * This means the mesh underlying bounding box and sphere are recomputed.
  24223. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24224. * @returns the current mesh
  24225. */
  24226. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24227. /** @hidden */
  24228. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24229. /**
  24230. * This function will subdivide the mesh into multiple submeshes
  24231. * @param count defines the expected number of submeshes
  24232. */
  24233. subdivide(count: number): void;
  24234. /**
  24235. * Copy a FloatArray into a specific associated vertex buffer
  24236. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24237. * - VertexBuffer.PositionKind
  24238. * - VertexBuffer.UVKind
  24239. * - VertexBuffer.UV2Kind
  24240. * - VertexBuffer.UV3Kind
  24241. * - VertexBuffer.UV4Kind
  24242. * - VertexBuffer.UV5Kind
  24243. * - VertexBuffer.UV6Kind
  24244. * - VertexBuffer.ColorKind
  24245. * - VertexBuffer.MatricesIndicesKind
  24246. * - VertexBuffer.MatricesIndicesExtraKind
  24247. * - VertexBuffer.MatricesWeightsKind
  24248. * - VertexBuffer.MatricesWeightsExtraKind
  24249. * @param data defines the data source
  24250. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24251. * @param stride defines the data stride size (can be null)
  24252. * @returns the current mesh
  24253. */
  24254. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24255. /**
  24256. * Delete a vertex buffer associated with this mesh
  24257. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24258. * - VertexBuffer.PositionKind
  24259. * - VertexBuffer.UVKind
  24260. * - VertexBuffer.UV2Kind
  24261. * - VertexBuffer.UV3Kind
  24262. * - VertexBuffer.UV4Kind
  24263. * - VertexBuffer.UV5Kind
  24264. * - VertexBuffer.UV6Kind
  24265. * - VertexBuffer.ColorKind
  24266. * - VertexBuffer.MatricesIndicesKind
  24267. * - VertexBuffer.MatricesIndicesExtraKind
  24268. * - VertexBuffer.MatricesWeightsKind
  24269. * - VertexBuffer.MatricesWeightsExtraKind
  24270. */
  24271. removeVerticesData(kind: string): void;
  24272. /**
  24273. * Flags an associated vertex buffer as updatable
  24274. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24275. * - VertexBuffer.PositionKind
  24276. * - VertexBuffer.UVKind
  24277. * - VertexBuffer.UV2Kind
  24278. * - VertexBuffer.UV3Kind
  24279. * - VertexBuffer.UV4Kind
  24280. * - VertexBuffer.UV5Kind
  24281. * - VertexBuffer.UV6Kind
  24282. * - VertexBuffer.ColorKind
  24283. * - VertexBuffer.MatricesIndicesKind
  24284. * - VertexBuffer.MatricesIndicesExtraKind
  24285. * - VertexBuffer.MatricesWeightsKind
  24286. * - VertexBuffer.MatricesWeightsExtraKind
  24287. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24288. */
  24289. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24290. /**
  24291. * Sets the mesh global Vertex Buffer
  24292. * @param buffer defines the buffer to use
  24293. * @returns the current mesh
  24294. */
  24295. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24296. /**
  24297. * Update a specific associated vertex buffer
  24298. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24299. * - VertexBuffer.PositionKind
  24300. * - VertexBuffer.UVKind
  24301. * - VertexBuffer.UV2Kind
  24302. * - VertexBuffer.UV3Kind
  24303. * - VertexBuffer.UV4Kind
  24304. * - VertexBuffer.UV5Kind
  24305. * - VertexBuffer.UV6Kind
  24306. * - VertexBuffer.ColorKind
  24307. * - VertexBuffer.MatricesIndicesKind
  24308. * - VertexBuffer.MatricesIndicesExtraKind
  24309. * - VertexBuffer.MatricesWeightsKind
  24310. * - VertexBuffer.MatricesWeightsExtraKind
  24311. * @param data defines the data source
  24312. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24313. * @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)
  24314. * @returns the current mesh
  24315. */
  24316. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24317. /**
  24318. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24319. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24320. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24321. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24322. * @returns the current mesh
  24323. */
  24324. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24325. /**
  24326. * Creates a un-shared specific occurence of the geometry for the mesh.
  24327. * @returns the current mesh
  24328. */
  24329. makeGeometryUnique(): Mesh;
  24330. /**
  24331. * Set the index buffer of this mesh
  24332. * @param indices defines the source data
  24333. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24334. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24335. * @returns the current mesh
  24336. */
  24337. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24338. /**
  24339. * Update the current index buffer
  24340. * @param indices defines the source data
  24341. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24342. * @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)
  24343. * @returns the current mesh
  24344. */
  24345. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24346. /**
  24347. * Invert the geometry to move from a right handed system to a left handed one.
  24348. * @returns the current mesh
  24349. */
  24350. toLeftHanded(): Mesh;
  24351. /** @hidden */
  24352. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24353. /** @hidden */
  24354. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24355. /**
  24356. * Registers for this mesh a javascript function called just before the rendering process
  24357. * @param func defines the function to call before rendering this mesh
  24358. * @returns the current mesh
  24359. */
  24360. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24361. /**
  24362. * Disposes a previously registered javascript function called before the rendering
  24363. * @param func defines the function to remove
  24364. * @returns the current mesh
  24365. */
  24366. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24367. /**
  24368. * Registers for this mesh a javascript function called just after the rendering is complete
  24369. * @param func defines the function to call after rendering this mesh
  24370. * @returns the current mesh
  24371. */
  24372. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24373. /**
  24374. * Disposes a previously registered javascript function called after the rendering.
  24375. * @param func defines the function to remove
  24376. * @returns the current mesh
  24377. */
  24378. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24379. /** @hidden */
  24380. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24381. /** @hidden */
  24382. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24383. /** @hidden */
  24384. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24385. /** @hidden */
  24386. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24387. /** @hidden */
  24388. _rebuild(): void;
  24389. /** @hidden */
  24390. _freeze(): void;
  24391. /** @hidden */
  24392. _unFreeze(): void;
  24393. /**
  24394. * 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
  24395. * @param subMesh defines the subMesh to render
  24396. * @param enableAlphaMode defines if alpha mode can be changed
  24397. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24398. * @returns the current mesh
  24399. */
  24400. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24401. private _onBeforeDraw;
  24402. /**
  24403. * Renormalize the mesh and patch it up if there are no weights
  24404. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24405. * However in the case of zero weights then we set just a single influence to 1.
  24406. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24407. */
  24408. cleanMatrixWeights(): void;
  24409. private normalizeSkinFourWeights;
  24410. private normalizeSkinWeightsAndExtra;
  24411. /**
  24412. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24413. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24414. * the user know there was an issue with importing the mesh
  24415. * @returns a validation object with skinned, valid and report string
  24416. */
  24417. validateSkinning(): {
  24418. skinned: boolean;
  24419. valid: boolean;
  24420. report: string;
  24421. };
  24422. /** @hidden */
  24423. _checkDelayState(): Mesh;
  24424. private _queueLoad;
  24425. /**
  24426. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24427. * A mesh is in the frustum if its bounding box intersects the frustum
  24428. * @param frustumPlanes defines the frustum to test
  24429. * @returns true if the mesh is in the frustum planes
  24430. */
  24431. isInFrustum(frustumPlanes: Plane[]): boolean;
  24432. /**
  24433. * Sets the mesh material by the material or multiMaterial `id` property
  24434. * @param id is a string identifying the material or the multiMaterial
  24435. * @returns the current mesh
  24436. */
  24437. setMaterialByID(id: string): Mesh;
  24438. /**
  24439. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24440. * @returns an array of IAnimatable
  24441. */
  24442. getAnimatables(): IAnimatable[];
  24443. /**
  24444. * Modifies the mesh geometry according to the passed transformation matrix.
  24445. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24446. * The mesh normals are modified using the same transformation.
  24447. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24448. * @param transform defines the transform matrix to use
  24449. * @see http://doc.babylonjs.com/resources/baking_transformations
  24450. * @returns the current mesh
  24451. */
  24452. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24453. /**
  24454. * Modifies the mesh geometry according to its own current World Matrix.
  24455. * The mesh World Matrix is then reset.
  24456. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24457. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24458. * @see http://doc.babylonjs.com/resources/baking_transformations
  24459. * @returns the current mesh
  24460. */
  24461. bakeCurrentTransformIntoVertices(): Mesh;
  24462. /** @hidden */
  24463. readonly _positions: Nullable<Vector3[]>;
  24464. /** @hidden */
  24465. _resetPointsArrayCache(): Mesh;
  24466. /** @hidden */
  24467. _generatePointsArray(): boolean;
  24468. /**
  24469. * Returns a new Mesh object generated from the current mesh properties.
  24470. * This method must not get confused with createInstance()
  24471. * @param name is a string, the name given to the new mesh
  24472. * @param newParent can be any Node object (default `null`)
  24473. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24474. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24475. * @returns a new mesh
  24476. */
  24477. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24478. /**
  24479. * Releases resources associated with this mesh.
  24480. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24481. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24482. */
  24483. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24484. /** @hidden */
  24485. _disposeInstanceSpecificData(): void;
  24486. /**
  24487. * Modifies the mesh geometry according to a displacement map.
  24488. * 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.
  24489. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24490. * @param url is a string, the URL from the image file is to be downloaded.
  24491. * @param minHeight is the lower limit of the displacement.
  24492. * @param maxHeight is the upper limit of the displacement.
  24493. * @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.
  24494. * @param uvOffset is an optional vector2 used to offset UV.
  24495. * @param uvScale is an optional vector2 used to scale UV.
  24496. * @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.
  24497. * @returns the Mesh.
  24498. */
  24499. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24500. /**
  24501. * Modifies the mesh geometry according to a displacementMap buffer.
  24502. * 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.
  24503. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24504. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24505. * @param heightMapWidth is the width of the buffer image.
  24506. * @param heightMapHeight is the height of the buffer image.
  24507. * @param minHeight is the lower limit of the displacement.
  24508. * @param maxHeight is the upper limit of the displacement.
  24509. * @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.
  24510. * @param uvOffset is an optional vector2 used to offset UV.
  24511. * @param uvScale is an optional vector2 used to scale UV.
  24512. * @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.
  24513. * @returns the Mesh.
  24514. */
  24515. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24516. /**
  24517. * Modify the mesh to get a flat shading rendering.
  24518. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24519. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24520. * @returns current mesh
  24521. */
  24522. convertToFlatShadedMesh(): Mesh;
  24523. /**
  24524. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24525. * In other words, more vertices, no more indices and a single bigger VBO.
  24526. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24527. * @returns current mesh
  24528. */
  24529. convertToUnIndexedMesh(): Mesh;
  24530. /**
  24531. * Inverses facet orientations.
  24532. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24533. * @param flipNormals will also inverts the normals
  24534. * @returns current mesh
  24535. */
  24536. flipFaces(flipNormals?: boolean): Mesh;
  24537. /**
  24538. * Increase the number of facets and hence vertices in a mesh
  24539. * Vertex normals are interpolated from existing vertex normals
  24540. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24541. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24542. */
  24543. increaseVertices(numberPerEdge: number): void;
  24544. /**
  24545. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24546. * This will undo any application of covertToFlatShadedMesh
  24547. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24548. */
  24549. forceSharedVertices(): void;
  24550. /** @hidden */
  24551. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24552. /** @hidden */
  24553. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24554. /**
  24555. * Creates a new InstancedMesh object from the mesh model.
  24556. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24557. * @param name defines the name of the new instance
  24558. * @returns a new InstancedMesh
  24559. */
  24560. createInstance(name: string): InstancedMesh;
  24561. /**
  24562. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24563. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24564. * @returns the current mesh
  24565. */
  24566. synchronizeInstances(): Mesh;
  24567. /**
  24568. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24569. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24570. * This should be used together with the simplification to avoid disappearing triangles.
  24571. * @param successCallback an optional success callback to be called after the optimization finished.
  24572. * @returns the current mesh
  24573. */
  24574. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24575. /**
  24576. * Serialize current mesh
  24577. * @param serializationObject defines the object which will receive the serialization data
  24578. */
  24579. serialize(serializationObject: any): void;
  24580. /** @hidden */
  24581. _syncGeometryWithMorphTargetManager(): void;
  24582. /** @hidden */
  24583. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24584. /**
  24585. * Returns a new Mesh object parsed from the source provided.
  24586. * @param parsedMesh is the source
  24587. * @param scene defines the hosting scene
  24588. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24589. * @returns a new Mesh
  24590. */
  24591. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24592. /**
  24593. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24594. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24595. * @param name defines the name of the mesh to create
  24596. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24597. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24598. * @param closePath creates a seam between the first and the last points of each path of the path array
  24599. * @param offset is taken in account only if the `pathArray` is containing a single path
  24600. * @param scene defines the hosting scene
  24601. * @param updatable defines if the mesh must be flagged as updatable
  24602. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24603. * @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)
  24604. * @returns a new Mesh
  24605. */
  24606. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24607. /**
  24608. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24609. * @param name defines the name of the mesh to create
  24610. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24611. * @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
  24612. * @param scene defines the hosting scene
  24613. * @param updatable defines if the mesh must be flagged as updatable
  24614. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24615. * @returns a new Mesh
  24616. */
  24617. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24618. /**
  24619. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24620. * @param name defines the name of the mesh to create
  24621. * @param size sets the size (float) of each box side (default 1)
  24622. * @param scene defines the hosting scene
  24623. * @param updatable defines if the mesh must be flagged as updatable
  24624. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24625. * @returns a new Mesh
  24626. */
  24627. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24628. /**
  24629. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24630. * @param name defines the name of the mesh to create
  24631. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24632. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24633. * @param scene defines the hosting scene
  24634. * @param updatable defines if the mesh must be flagged as updatable
  24635. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24636. * @returns a new Mesh
  24637. */
  24638. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24639. /**
  24640. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24641. * @param name defines the name of the mesh to create
  24642. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24643. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24644. * @param scene defines the hosting scene
  24645. * @returns a new Mesh
  24646. */
  24647. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24648. /**
  24649. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24650. * @param name defines the name of the mesh to create
  24651. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24652. * @param diameterTop set the top cap diameter (floats, default 1)
  24653. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24654. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24655. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24656. * @param scene defines the hosting scene
  24657. * @param updatable defines if the mesh must be flagged as updatable
  24658. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24659. * @returns a new Mesh
  24660. */
  24661. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24662. /**
  24663. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24664. * @param name defines the name of the mesh to create
  24665. * @param diameter sets the diameter size (float) of the torus (default 1)
  24666. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24667. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24668. * @param scene defines the hosting scene
  24669. * @param updatable defines if the mesh must be flagged as updatable
  24670. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24671. * @returns a new Mesh
  24672. */
  24673. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24674. /**
  24675. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24676. * @param name defines the name of the mesh to create
  24677. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24678. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24679. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24680. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24681. * @param p the number of windings on X axis (positive integers, default 2)
  24682. * @param q the number of windings on Y axis (positive integers, default 3)
  24683. * @param scene defines the hosting scene
  24684. * @param updatable defines if the mesh must be flagged as updatable
  24685. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24686. * @returns a new Mesh
  24687. */
  24688. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24689. /**
  24690. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24691. * @param name defines the name of the mesh to create
  24692. * @param points is an array successive Vector3
  24693. * @param scene defines the hosting scene
  24694. * @param updatable defines if the mesh must be flagged as updatable
  24695. * @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).
  24696. * @returns a new Mesh
  24697. */
  24698. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24699. /**
  24700. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24701. * @param name defines the name of the mesh to create
  24702. * @param points is an array successive Vector3
  24703. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24704. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24705. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24706. * @param scene defines the hosting scene
  24707. * @param updatable defines if the mesh must be flagged as updatable
  24708. * @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)
  24709. * @returns a new Mesh
  24710. */
  24711. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24712. /**
  24713. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24714. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24715. * 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.
  24716. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24717. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24718. * Remember you can only change the shape positions, not their number when updating a polygon.
  24719. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24720. * @param name defines the name of the mesh to create
  24721. * @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
  24722. * @param scene defines the hosting scene
  24723. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24724. * @param updatable defines if the mesh must be flagged as updatable
  24725. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24726. * @param earcutInjection can be used to inject your own earcut reference
  24727. * @returns a new Mesh
  24728. */
  24729. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24730. /**
  24731. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24732. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24733. * @param name defines the name of the mesh to create
  24734. * @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
  24735. * @param depth defines the height of extrusion
  24736. * @param scene defines the hosting scene
  24737. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24738. * @param updatable defines if the mesh must be flagged as updatable
  24739. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24740. * @param earcutInjection can be used to inject your own earcut reference
  24741. * @returns a new Mesh
  24742. */
  24743. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24744. /**
  24745. * Creates an extruded shape mesh.
  24746. * 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
  24747. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24748. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24749. * @param name defines the name of the mesh to create
  24750. * @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
  24751. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24752. * @param scale is the value to scale the shape
  24753. * @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
  24754. * @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
  24755. * @param scene defines the hosting scene
  24756. * @param updatable defines if the mesh must be flagged as updatable
  24757. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24758. * @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)
  24759. * @returns a new Mesh
  24760. */
  24761. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24762. /**
  24763. * Creates an custom extruded shape mesh.
  24764. * The custom extrusion is a parametric shape.
  24765. * It has no predefined shape. Its final shape will depend on the input parameters.
  24766. * Please consider using the same method from the MeshBuilder class instead
  24767. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24768. * @param name defines the name of the mesh to create
  24769. * @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
  24770. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24771. * @param scaleFunction is a custom Javascript function called on each path point
  24772. * @param rotationFunction is a custom Javascript function called on each path point
  24773. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24774. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24775. * @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
  24776. * @param scene defines the hosting scene
  24777. * @param updatable defines if the mesh must be flagged as updatable
  24778. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24779. * @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)
  24780. * @returns a new Mesh
  24781. */
  24782. 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;
  24783. /**
  24784. * Creates lathe mesh.
  24785. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24786. * Please consider using the same method from the MeshBuilder class instead
  24787. * @param name defines the name of the mesh to create
  24788. * @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
  24789. * @param radius is the radius value of the lathe
  24790. * @param tessellation is the side number of the lathe.
  24791. * @param scene defines the hosting scene
  24792. * @param updatable defines if the mesh must be flagged as updatable
  24793. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24794. * @returns a new Mesh
  24795. */
  24796. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24797. /**
  24798. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24799. * @param name defines the name of the mesh to create
  24800. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24801. * @param scene defines the hosting scene
  24802. * @param updatable defines if the mesh must be flagged as updatable
  24803. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24804. * @returns a new Mesh
  24805. */
  24806. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24807. /**
  24808. * Creates a ground mesh.
  24809. * Please consider using the same method from the MeshBuilder class instead
  24810. * @param name defines the name of the mesh to create
  24811. * @param width set the width of the ground
  24812. * @param height set the height of the ground
  24813. * @param subdivisions sets the number of subdivisions per side
  24814. * @param scene defines the hosting scene
  24815. * @param updatable defines if the mesh must be flagged as updatable
  24816. * @returns a new Mesh
  24817. */
  24818. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24819. /**
  24820. * Creates a tiled ground mesh.
  24821. * Please consider using the same method from the MeshBuilder class instead
  24822. * @param name defines the name of the mesh to create
  24823. * @param xmin set the ground minimum X coordinate
  24824. * @param zmin set the ground minimum Y coordinate
  24825. * @param xmax set the ground maximum X coordinate
  24826. * @param zmax set the ground maximum Z coordinate
  24827. * @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
  24828. * @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
  24829. * @param scene defines the hosting scene
  24830. * @param updatable defines if the mesh must be flagged as updatable
  24831. * @returns a new Mesh
  24832. */
  24833. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24834. w: number;
  24835. h: number;
  24836. }, precision: {
  24837. w: number;
  24838. h: number;
  24839. }, scene: Scene, updatable?: boolean): Mesh;
  24840. /**
  24841. * Creates a ground mesh from a height map.
  24842. * Please consider using the same method from the MeshBuilder class instead
  24843. * @see http://doc.babylonjs.com/babylon101/height_map
  24844. * @param name defines the name of the mesh to create
  24845. * @param url sets the URL of the height map image resource
  24846. * @param width set the ground width size
  24847. * @param height set the ground height size
  24848. * @param subdivisions sets the number of subdivision per side
  24849. * @param minHeight is the minimum altitude on the ground
  24850. * @param maxHeight is the maximum altitude on the ground
  24851. * @param scene defines the hosting scene
  24852. * @param updatable defines if the mesh must be flagged as updatable
  24853. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24854. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24855. * @returns a new Mesh
  24856. */
  24857. 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;
  24858. /**
  24859. * Creates a tube mesh.
  24860. * The tube is a parametric shape.
  24861. * It has no predefined shape. Its final shape will depend on the input parameters.
  24862. * Please consider using the same method from the MeshBuilder class instead
  24863. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24864. * @param name defines the name of the mesh to create
  24865. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24866. * @param radius sets the tube radius size
  24867. * @param tessellation is the number of sides on the tubular surface
  24868. * @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
  24869. * @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
  24870. * @param scene defines the hosting scene
  24871. * @param updatable defines if the mesh must be flagged as updatable
  24872. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24873. * @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)
  24874. * @returns a new Mesh
  24875. */
  24876. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24877. (i: number, distance: number): number;
  24878. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24879. /**
  24880. * Creates a polyhedron mesh.
  24881. * Please consider using the same method from the MeshBuilder class instead.
  24882. * * 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
  24883. * * The parameter `size` (positive float, default 1) sets the polygon size
  24884. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24885. * * 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`
  24886. * * 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
  24887. * * 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)`)
  24888. * * 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
  24889. * * 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
  24890. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24891. * * 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
  24892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24893. * @param name defines the name of the mesh to create
  24894. * @param options defines the options used to create the mesh
  24895. * @param scene defines the hosting scene
  24896. * @returns a new Mesh
  24897. */
  24898. static CreatePolyhedron(name: string, options: {
  24899. type?: number;
  24900. size?: number;
  24901. sizeX?: number;
  24902. sizeY?: number;
  24903. sizeZ?: number;
  24904. custom?: any;
  24905. faceUV?: Vector4[];
  24906. faceColors?: Color4[];
  24907. updatable?: boolean;
  24908. sideOrientation?: number;
  24909. }, scene: Scene): Mesh;
  24910. /**
  24911. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24912. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24913. * * 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`)
  24914. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24915. * * 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
  24916. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24917. * * 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
  24918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24919. * @param name defines the name of the mesh
  24920. * @param options defines the options used to create the mesh
  24921. * @param scene defines the hosting scene
  24922. * @returns a new Mesh
  24923. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24924. */
  24925. static CreateIcoSphere(name: string, options: {
  24926. radius?: number;
  24927. flat?: boolean;
  24928. subdivisions?: number;
  24929. sideOrientation?: number;
  24930. updatable?: boolean;
  24931. }, scene: Scene): Mesh;
  24932. /**
  24933. * Creates a decal mesh.
  24934. * Please consider using the same method from the MeshBuilder class instead.
  24935. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24936. * @param name defines the name of the mesh
  24937. * @param sourceMesh defines the mesh receiving the decal
  24938. * @param position sets the position of the decal in world coordinates
  24939. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24940. * @param size sets the decal scaling
  24941. * @param angle sets the angle to rotate the decal
  24942. * @returns a new Mesh
  24943. */
  24944. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24945. /**
  24946. * Prepare internal position array for software CPU skinning
  24947. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24948. */
  24949. setPositionsForCPUSkinning(): Float32Array;
  24950. /**
  24951. * Prepare internal normal array for software CPU skinning
  24952. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24953. */
  24954. setNormalsForCPUSkinning(): Float32Array;
  24955. /**
  24956. * Updates the vertex buffer by applying transformation from the bones
  24957. * @param skeleton defines the skeleton to apply to current mesh
  24958. * @returns the current mesh
  24959. */
  24960. applySkeleton(skeleton: Skeleton): Mesh;
  24961. /**
  24962. * 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
  24963. * @param meshes defines the list of meshes to scan
  24964. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24965. */
  24966. static MinMax(meshes: AbstractMesh[]): {
  24967. min: Vector3;
  24968. max: Vector3;
  24969. };
  24970. /**
  24971. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24972. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24973. * @returns a vector3
  24974. */
  24975. static Center(meshesOrMinMaxVector: {
  24976. min: Vector3;
  24977. max: Vector3;
  24978. } | AbstractMesh[]): Vector3;
  24979. /**
  24980. * Merge the array of meshes into a single mesh for performance reasons.
  24981. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24982. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24983. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24984. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24985. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24986. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24987. * @returns a new mesh
  24988. */
  24989. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24990. /** @hidden */
  24991. addInstance(instance: InstancedMesh): void;
  24992. /** @hidden */
  24993. removeInstance(instance: InstancedMesh): void;
  24994. }
  24995. }
  24996. declare module BABYLON {
  24997. /**
  24998. * This is the base class of all the camera used in the application.
  24999. * @see http://doc.babylonjs.com/features/cameras
  25000. */
  25001. export class Camera extends Node {
  25002. /** @hidden */
  25003. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25004. /**
  25005. * This is the default projection mode used by the cameras.
  25006. * It helps recreating a feeling of perspective and better appreciate depth.
  25007. * This is the best way to simulate real life cameras.
  25008. */
  25009. static readonly PERSPECTIVE_CAMERA: number;
  25010. /**
  25011. * This helps creating camera with an orthographic mode.
  25012. * 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.
  25013. */
  25014. static readonly ORTHOGRAPHIC_CAMERA: number;
  25015. /**
  25016. * This is the default FOV mode for perspective cameras.
  25017. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25018. */
  25019. static readonly FOVMODE_VERTICAL_FIXED: number;
  25020. /**
  25021. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25022. */
  25023. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25024. /**
  25025. * This specifies ther is no need for a camera rig.
  25026. * Basically only one eye is rendered corresponding to the camera.
  25027. */
  25028. static readonly RIG_MODE_NONE: number;
  25029. /**
  25030. * Simulates a camera Rig with one blue eye and one red eye.
  25031. * This can be use with 3d blue and red glasses.
  25032. */
  25033. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25034. /**
  25035. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25036. */
  25037. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25038. /**
  25039. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25040. */
  25041. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25042. /**
  25043. * Defines that both eyes of the camera will be rendered over under each other.
  25044. */
  25045. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25046. /**
  25047. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25048. */
  25049. static readonly RIG_MODE_VR: number;
  25050. /**
  25051. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25052. */
  25053. static readonly RIG_MODE_WEBVR: number;
  25054. /**
  25055. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25056. */
  25057. static readonly RIG_MODE_CUSTOM: number;
  25058. /**
  25059. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25060. */
  25061. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25062. /**
  25063. * Define the input manager associated with the camera.
  25064. */
  25065. inputs: CameraInputsManager<Camera>;
  25066. /** @hidden */
  25067. _position: Vector3;
  25068. /**
  25069. * Define the current local position of the camera in the scene
  25070. */
  25071. position: Vector3;
  25072. /**
  25073. * The vector the camera should consider as up.
  25074. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25075. */
  25076. upVector: Vector3;
  25077. /**
  25078. * Define the current limit on the left side for an orthographic camera
  25079. * In scene unit
  25080. */
  25081. orthoLeft: Nullable<number>;
  25082. /**
  25083. * Define the current limit on the right side for an orthographic camera
  25084. * In scene unit
  25085. */
  25086. orthoRight: Nullable<number>;
  25087. /**
  25088. * Define the current limit on the bottom side for an orthographic camera
  25089. * In scene unit
  25090. */
  25091. orthoBottom: Nullable<number>;
  25092. /**
  25093. * Define the current limit on the top side for an orthographic camera
  25094. * In scene unit
  25095. */
  25096. orthoTop: Nullable<number>;
  25097. /**
  25098. * Field Of View is set in Radians. (default is 0.8)
  25099. */
  25100. fov: number;
  25101. /**
  25102. * Define the minimum distance the camera can see from.
  25103. * This is important to note that the depth buffer are not infinite and the closer it starts
  25104. * the more your scene might encounter depth fighting issue.
  25105. */
  25106. minZ: number;
  25107. /**
  25108. * Define the maximum distance the camera can see to.
  25109. * This is important to note that the depth buffer are not infinite and the further it end
  25110. * the more your scene might encounter depth fighting issue.
  25111. */
  25112. maxZ: number;
  25113. /**
  25114. * Define the default inertia of the camera.
  25115. * This helps giving a smooth feeling to the camera movement.
  25116. */
  25117. inertia: number;
  25118. /**
  25119. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25120. */
  25121. mode: number;
  25122. /**
  25123. * Define wether the camera is intermediate.
  25124. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25125. */
  25126. isIntermediate: boolean;
  25127. /**
  25128. * Define the viewport of the camera.
  25129. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25130. */
  25131. viewport: Viewport;
  25132. /**
  25133. * Restricts the camera to viewing objects with the same layerMask.
  25134. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25135. */
  25136. layerMask: number;
  25137. /**
  25138. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25139. */
  25140. fovMode: number;
  25141. /**
  25142. * Rig mode of the camera.
  25143. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25144. * This is normally controlled byt the camera themselves as internal use.
  25145. */
  25146. cameraRigMode: number;
  25147. /**
  25148. * Defines the distance between both "eyes" in case of a RIG
  25149. */
  25150. interaxialDistance: number;
  25151. /**
  25152. * Defines if stereoscopic rendering is done side by side or over under.
  25153. */
  25154. isStereoscopicSideBySide: boolean;
  25155. /**
  25156. * 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
  25157. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25158. * else in the scene. (Eg. security camera)
  25159. *
  25160. * 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)
  25161. */
  25162. customRenderTargets: RenderTargetTexture[];
  25163. /**
  25164. * When set, the camera will render to this render target instead of the default canvas
  25165. *
  25166. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25167. */
  25168. outputRenderTarget: Nullable<RenderTargetTexture>;
  25169. /**
  25170. * Observable triggered when the camera view matrix has changed.
  25171. */
  25172. onViewMatrixChangedObservable: Observable<Camera>;
  25173. /**
  25174. * Observable triggered when the camera Projection matrix has changed.
  25175. */
  25176. onProjectionMatrixChangedObservable: Observable<Camera>;
  25177. /**
  25178. * Observable triggered when the inputs have been processed.
  25179. */
  25180. onAfterCheckInputsObservable: Observable<Camera>;
  25181. /**
  25182. * Observable triggered when reset has been called and applied to the camera.
  25183. */
  25184. onRestoreStateObservable: Observable<Camera>;
  25185. /** @hidden */
  25186. _cameraRigParams: any;
  25187. /** @hidden */
  25188. _rigCameras: Camera[];
  25189. /** @hidden */
  25190. _rigPostProcess: Nullable<PostProcess>;
  25191. protected _webvrViewMatrix: Matrix;
  25192. /** @hidden */
  25193. _skipRendering: boolean;
  25194. /** @hidden */
  25195. _projectionMatrix: Matrix;
  25196. /** @hidden */
  25197. _postProcesses: Nullable<PostProcess>[];
  25198. /** @hidden */
  25199. _activeMeshes: SmartArray<AbstractMesh>;
  25200. protected _globalPosition: Vector3;
  25201. /** @hidden */
  25202. _computedViewMatrix: Matrix;
  25203. private _doNotComputeProjectionMatrix;
  25204. private _transformMatrix;
  25205. private _frustumPlanes;
  25206. private _refreshFrustumPlanes;
  25207. private _storedFov;
  25208. private _stateStored;
  25209. /**
  25210. * Instantiates a new camera object.
  25211. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25212. * @see http://doc.babylonjs.com/features/cameras
  25213. * @param name Defines the name of the camera in the scene
  25214. * @param position Defines the position of the camera
  25215. * @param scene Defines the scene the camera belongs too
  25216. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25217. */
  25218. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25219. /**
  25220. * Store current camera state (fov, position, etc..)
  25221. * @returns the camera
  25222. */
  25223. storeState(): Camera;
  25224. /**
  25225. * Restores the camera state values if it has been stored. You must call storeState() first
  25226. */
  25227. protected _restoreStateValues(): boolean;
  25228. /**
  25229. * Restored camera state. You must call storeState() first.
  25230. * @returns true if restored and false otherwise
  25231. */
  25232. restoreState(): boolean;
  25233. /**
  25234. * Gets the class name of the camera.
  25235. * @returns the class name
  25236. */
  25237. getClassName(): string;
  25238. /** @hidden */
  25239. readonly _isCamera: boolean;
  25240. /**
  25241. * Gets a string representation of the camera useful for debug purpose.
  25242. * @param fullDetails Defines that a more verboe level of logging is required
  25243. * @returns the string representation
  25244. */
  25245. toString(fullDetails?: boolean): string;
  25246. /**
  25247. * Gets the current world space position of the camera.
  25248. */
  25249. readonly globalPosition: Vector3;
  25250. /**
  25251. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25252. * @returns the active meshe list
  25253. */
  25254. getActiveMeshes(): SmartArray<AbstractMesh>;
  25255. /**
  25256. * Check wether a mesh is part of the current active mesh list of the camera
  25257. * @param mesh Defines the mesh to check
  25258. * @returns true if active, false otherwise
  25259. */
  25260. isActiveMesh(mesh: Mesh): boolean;
  25261. /**
  25262. * Is this camera ready to be used/rendered
  25263. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25264. * @return true if the camera is ready
  25265. */
  25266. isReady(completeCheck?: boolean): boolean;
  25267. /** @hidden */
  25268. _initCache(): void;
  25269. /** @hidden */
  25270. _updateCache(ignoreParentClass?: boolean): void;
  25271. /** @hidden */
  25272. _isSynchronized(): boolean;
  25273. /** @hidden */
  25274. _isSynchronizedViewMatrix(): boolean;
  25275. /** @hidden */
  25276. _isSynchronizedProjectionMatrix(): boolean;
  25277. /**
  25278. * Attach the input controls to a specific dom element to get the input from.
  25279. * @param element Defines the element the controls should be listened from
  25280. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25281. */
  25282. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25283. /**
  25284. * Detach the current controls from the specified dom element.
  25285. * @param element Defines the element to stop listening the inputs from
  25286. */
  25287. detachControl(element: HTMLElement): void;
  25288. /**
  25289. * Update the camera state according to the different inputs gathered during the frame.
  25290. */
  25291. update(): void;
  25292. /** @hidden */
  25293. _checkInputs(): void;
  25294. /** @hidden */
  25295. readonly rigCameras: Camera[];
  25296. /**
  25297. * Gets the post process used by the rig cameras
  25298. */
  25299. readonly rigPostProcess: Nullable<PostProcess>;
  25300. /**
  25301. * Internal, gets the first post proces.
  25302. * @returns the first post process to be run on this camera.
  25303. */
  25304. _getFirstPostProcess(): Nullable<PostProcess>;
  25305. private _cascadePostProcessesToRigCams;
  25306. /**
  25307. * Attach a post process to the camera.
  25308. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25309. * @param postProcess The post process to attach to the camera
  25310. * @param insertAt The position of the post process in case several of them are in use in the scene
  25311. * @returns the position the post process has been inserted at
  25312. */
  25313. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25314. /**
  25315. * Detach a post process to the camera.
  25316. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25317. * @param postProcess The post process to detach from the camera
  25318. */
  25319. detachPostProcess(postProcess: PostProcess): void;
  25320. /**
  25321. * Gets the current world matrix of the camera
  25322. */
  25323. getWorldMatrix(): Matrix;
  25324. /** @hidden */
  25325. _getViewMatrix(): Matrix;
  25326. /**
  25327. * Gets the current view matrix of the camera.
  25328. * @param force forces the camera to recompute the matrix without looking at the cached state
  25329. * @returns the view matrix
  25330. */
  25331. getViewMatrix(force?: boolean): Matrix;
  25332. /**
  25333. * Freeze the projection matrix.
  25334. * It will prevent the cache check of the camera projection compute and can speed up perf
  25335. * if no parameter of the camera are meant to change
  25336. * @param projection Defines manually a projection if necessary
  25337. */
  25338. freezeProjectionMatrix(projection?: Matrix): void;
  25339. /**
  25340. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25341. */
  25342. unfreezeProjectionMatrix(): void;
  25343. /**
  25344. * Gets the current projection matrix of the camera.
  25345. * @param force forces the camera to recompute the matrix without looking at the cached state
  25346. * @returns the projection matrix
  25347. */
  25348. getProjectionMatrix(force?: boolean): Matrix;
  25349. /**
  25350. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25351. * @returns a Matrix
  25352. */
  25353. getTransformationMatrix(): Matrix;
  25354. private _updateFrustumPlanes;
  25355. /**
  25356. * Checks if a cullable object (mesh...) is in the camera frustum
  25357. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25358. * @param target The object to check
  25359. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25360. * @returns true if the object is in frustum otherwise false
  25361. */
  25362. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25363. /**
  25364. * Checks if a cullable object (mesh...) is in the camera frustum
  25365. * Unlike isInFrustum this cheks the full bounding box
  25366. * @param target The object to check
  25367. * @returns true if the object is in frustum otherwise false
  25368. */
  25369. isCompletelyInFrustum(target: ICullable): boolean;
  25370. /**
  25371. * Gets a ray in the forward direction from the camera.
  25372. * @param length Defines the length of the ray to create
  25373. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25374. * @param origin Defines the start point of the ray which defaults to the camera position
  25375. * @returns the forward ray
  25376. */
  25377. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25378. /**
  25379. * Releases resources associated with this node.
  25380. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25381. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25382. */
  25383. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25384. /** @hidden */
  25385. _isLeftCamera: boolean;
  25386. /**
  25387. * Gets the left camera of a rig setup in case of Rigged Camera
  25388. */
  25389. readonly isLeftCamera: boolean;
  25390. /** @hidden */
  25391. _isRightCamera: boolean;
  25392. /**
  25393. * Gets the right camera of a rig setup in case of Rigged Camera
  25394. */
  25395. readonly isRightCamera: boolean;
  25396. /**
  25397. * Gets the left camera of a rig setup in case of Rigged Camera
  25398. */
  25399. readonly leftCamera: Nullable<FreeCamera>;
  25400. /**
  25401. * Gets the right camera of a rig setup in case of Rigged Camera
  25402. */
  25403. readonly rightCamera: Nullable<FreeCamera>;
  25404. /**
  25405. * Gets the left camera target of a rig setup in case of Rigged Camera
  25406. * @returns the target position
  25407. */
  25408. getLeftTarget(): Nullable<Vector3>;
  25409. /**
  25410. * Gets the right camera target of a rig setup in case of Rigged Camera
  25411. * @returns the target position
  25412. */
  25413. getRightTarget(): Nullable<Vector3>;
  25414. /**
  25415. * @hidden
  25416. */
  25417. setCameraRigMode(mode: number, rigParams: any): void;
  25418. /** @hidden */
  25419. static _setStereoscopicRigMode(camera: Camera): void;
  25420. /** @hidden */
  25421. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25422. /** @hidden */
  25423. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25424. /** @hidden */
  25425. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25426. /** @hidden */
  25427. _getVRProjectionMatrix(): Matrix;
  25428. protected _updateCameraRotationMatrix(): void;
  25429. protected _updateWebVRCameraRotationMatrix(): void;
  25430. /**
  25431. * This function MUST be overwritten by the different WebVR cameras available.
  25432. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25433. * @hidden
  25434. */
  25435. _getWebVRProjectionMatrix(): Matrix;
  25436. /**
  25437. * This function MUST be overwritten by the different WebVR cameras available.
  25438. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25439. * @hidden
  25440. */
  25441. _getWebVRViewMatrix(): Matrix;
  25442. /** @hidden */
  25443. setCameraRigParameter(name: string, value: any): void;
  25444. /**
  25445. * needs to be overridden by children so sub has required properties to be copied
  25446. * @hidden
  25447. */
  25448. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25449. /**
  25450. * May need to be overridden by children
  25451. * @hidden
  25452. */
  25453. _updateRigCameras(): void;
  25454. /** @hidden */
  25455. _setupInputs(): void;
  25456. /**
  25457. * Serialiaze the camera setup to a json represention
  25458. * @returns the JSON representation
  25459. */
  25460. serialize(): any;
  25461. /**
  25462. * Clones the current camera.
  25463. * @param name The cloned camera name
  25464. * @returns the cloned camera
  25465. */
  25466. clone(name: string): Camera;
  25467. /**
  25468. * Gets the direction of the camera relative to a given local axis.
  25469. * @param localAxis Defines the reference axis to provide a relative direction.
  25470. * @return the direction
  25471. */
  25472. getDirection(localAxis: Vector3): Vector3;
  25473. /**
  25474. * Returns the current camera absolute rotation
  25475. */
  25476. readonly absoluteRotation: Quaternion;
  25477. /**
  25478. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25479. * @param localAxis Defines the reference axis to provide a relative direction.
  25480. * @param result Defines the vector to store the result in
  25481. */
  25482. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25483. /**
  25484. * Gets a camera constructor for a given camera type
  25485. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25486. * @param name The name of the camera the result will be able to instantiate
  25487. * @param scene The scene the result will construct the camera in
  25488. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25489. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25490. * @returns a factory method to construc the camera
  25491. */
  25492. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25493. /**
  25494. * Compute the world matrix of the camera.
  25495. * @returns the camera world matrix
  25496. */
  25497. computeWorldMatrix(): Matrix;
  25498. /**
  25499. * Parse a JSON and creates the camera from the parsed information
  25500. * @param parsedCamera The JSON to parse
  25501. * @param scene The scene to instantiate the camera in
  25502. * @returns the newly constructed camera
  25503. */
  25504. static Parse(parsedCamera: any, scene: Scene): Camera;
  25505. }
  25506. }
  25507. declare module BABYLON {
  25508. /**
  25509. * Class containing static functions to help procedurally build meshes
  25510. */
  25511. export class DiscBuilder {
  25512. /**
  25513. * Creates a plane polygonal mesh. By default, this is a disc
  25514. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25515. * * 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
  25516. * * 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
  25517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25518. * * 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
  25519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25520. * @param name defines the name of the mesh
  25521. * @param options defines the options used to create the mesh
  25522. * @param scene defines the hosting scene
  25523. * @returns the plane polygonal mesh
  25524. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25525. */
  25526. static CreateDisc(name: string, options: {
  25527. radius?: number;
  25528. tessellation?: number;
  25529. arc?: number;
  25530. updatable?: boolean;
  25531. sideOrientation?: number;
  25532. frontUVs?: Vector4;
  25533. backUVs?: Vector4;
  25534. }, scene?: Nullable<Scene>): Mesh;
  25535. }
  25536. }
  25537. declare module BABYLON {
  25538. /**
  25539. * This represents all the required information to add a fresnel effect on a material:
  25540. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25541. */
  25542. export class FresnelParameters {
  25543. private _isEnabled;
  25544. /**
  25545. * Define if the fresnel effect is enable or not.
  25546. */
  25547. isEnabled: boolean;
  25548. /**
  25549. * Define the color used on edges (grazing angle)
  25550. */
  25551. leftColor: Color3;
  25552. /**
  25553. * Define the color used on center
  25554. */
  25555. rightColor: Color3;
  25556. /**
  25557. * Define bias applied to computed fresnel term
  25558. */
  25559. bias: number;
  25560. /**
  25561. * Defined the power exponent applied to fresnel term
  25562. */
  25563. power: number;
  25564. /**
  25565. * Clones the current fresnel and its valuues
  25566. * @returns a clone fresnel configuration
  25567. */
  25568. clone(): FresnelParameters;
  25569. /**
  25570. * Serializes the current fresnel parameters to a JSON representation.
  25571. * @return the JSON serialization
  25572. */
  25573. serialize(): any;
  25574. /**
  25575. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25576. * @param parsedFresnelParameters Define the JSON representation
  25577. * @returns the parsed parameters
  25578. */
  25579. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25580. }
  25581. }
  25582. declare module BABYLON {
  25583. /**
  25584. * Base class of materials working in push mode in babylon JS
  25585. * @hidden
  25586. */
  25587. export class PushMaterial extends Material {
  25588. protected _activeEffect: Effect;
  25589. protected _normalMatrix: Matrix;
  25590. /**
  25591. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  25592. * This means that the material can keep using a previous shader while a new one is being compiled.
  25593. * This is mostly used when shader parallel compilation is supported (true by default)
  25594. */
  25595. allowShaderHotSwapping: boolean;
  25596. constructor(name: string, scene: Scene);
  25597. getEffect(): Effect;
  25598. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25599. /**
  25600. * Binds the given world matrix to the active effect
  25601. *
  25602. * @param world the matrix to bind
  25603. */
  25604. bindOnlyWorldMatrix(world: Matrix): void;
  25605. /**
  25606. * Binds the given normal matrix to the active effect
  25607. *
  25608. * @param normalMatrix the matrix to bind
  25609. */
  25610. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  25611. bind(world: Matrix, mesh?: Mesh): void;
  25612. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  25613. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  25614. }
  25615. }
  25616. declare module BABYLON {
  25617. /**
  25618. * This groups all the flags used to control the materials channel.
  25619. */
  25620. export class MaterialFlags {
  25621. private static _DiffuseTextureEnabled;
  25622. /**
  25623. * Are diffuse textures enabled in the application.
  25624. */
  25625. static DiffuseTextureEnabled: boolean;
  25626. private static _AmbientTextureEnabled;
  25627. /**
  25628. * Are ambient textures enabled in the application.
  25629. */
  25630. static AmbientTextureEnabled: boolean;
  25631. private static _OpacityTextureEnabled;
  25632. /**
  25633. * Are opacity textures enabled in the application.
  25634. */
  25635. static OpacityTextureEnabled: boolean;
  25636. private static _ReflectionTextureEnabled;
  25637. /**
  25638. * Are reflection textures enabled in the application.
  25639. */
  25640. static ReflectionTextureEnabled: boolean;
  25641. private static _EmissiveTextureEnabled;
  25642. /**
  25643. * Are emissive textures enabled in the application.
  25644. */
  25645. static EmissiveTextureEnabled: boolean;
  25646. private static _SpecularTextureEnabled;
  25647. /**
  25648. * Are specular textures enabled in the application.
  25649. */
  25650. static SpecularTextureEnabled: boolean;
  25651. private static _BumpTextureEnabled;
  25652. /**
  25653. * Are bump textures enabled in the application.
  25654. */
  25655. static BumpTextureEnabled: boolean;
  25656. private static _LightmapTextureEnabled;
  25657. /**
  25658. * Are lightmap textures enabled in the application.
  25659. */
  25660. static LightmapTextureEnabled: boolean;
  25661. private static _RefractionTextureEnabled;
  25662. /**
  25663. * Are refraction textures enabled in the application.
  25664. */
  25665. static RefractionTextureEnabled: boolean;
  25666. private static _ColorGradingTextureEnabled;
  25667. /**
  25668. * Are color grading textures enabled in the application.
  25669. */
  25670. static ColorGradingTextureEnabled: boolean;
  25671. private static _FresnelEnabled;
  25672. /**
  25673. * Are fresnels enabled in the application.
  25674. */
  25675. static FresnelEnabled: boolean;
  25676. private static _ClearCoatTextureEnabled;
  25677. /**
  25678. * Are clear coat textures enabled in the application.
  25679. */
  25680. static ClearCoatTextureEnabled: boolean;
  25681. private static _ClearCoatBumpTextureEnabled;
  25682. /**
  25683. * Are clear coat bump textures enabled in the application.
  25684. */
  25685. static ClearCoatBumpTextureEnabled: boolean;
  25686. private static _ClearCoatTintTextureEnabled;
  25687. /**
  25688. * Are clear coat tint textures enabled in the application.
  25689. */
  25690. static ClearCoatTintTextureEnabled: boolean;
  25691. private static _SheenTextureEnabled;
  25692. /**
  25693. * Are sheen textures enabled in the application.
  25694. */
  25695. static SheenTextureEnabled: boolean;
  25696. private static _AnisotropicTextureEnabled;
  25697. /**
  25698. * Are anisotropic textures enabled in the application.
  25699. */
  25700. static AnisotropicTextureEnabled: boolean;
  25701. private static _ThicknessTextureEnabled;
  25702. /**
  25703. * Are thickness textures enabled in the application.
  25704. */
  25705. static ThicknessTextureEnabled: boolean;
  25706. }
  25707. }
  25708. declare module BABYLON {
  25709. /** @hidden */
  25710. export var defaultFragmentDeclaration: {
  25711. name: string;
  25712. shader: string;
  25713. };
  25714. }
  25715. declare module BABYLON {
  25716. /** @hidden */
  25717. export var defaultUboDeclaration: {
  25718. name: string;
  25719. shader: string;
  25720. };
  25721. }
  25722. declare module BABYLON {
  25723. /** @hidden */
  25724. export var lightFragmentDeclaration: {
  25725. name: string;
  25726. shader: string;
  25727. };
  25728. }
  25729. declare module BABYLON {
  25730. /** @hidden */
  25731. export var lightUboDeclaration: {
  25732. name: string;
  25733. shader: string;
  25734. };
  25735. }
  25736. declare module BABYLON {
  25737. /** @hidden */
  25738. export var lightsFragmentFunctions: {
  25739. name: string;
  25740. shader: string;
  25741. };
  25742. }
  25743. declare module BABYLON {
  25744. /** @hidden */
  25745. export var shadowsFragmentFunctions: {
  25746. name: string;
  25747. shader: string;
  25748. };
  25749. }
  25750. declare module BABYLON {
  25751. /** @hidden */
  25752. export var fresnelFunction: {
  25753. name: string;
  25754. shader: string;
  25755. };
  25756. }
  25757. declare module BABYLON {
  25758. /** @hidden */
  25759. export var reflectionFunction: {
  25760. name: string;
  25761. shader: string;
  25762. };
  25763. }
  25764. declare module BABYLON {
  25765. /** @hidden */
  25766. export var bumpFragmentFunctions: {
  25767. name: string;
  25768. shader: string;
  25769. };
  25770. }
  25771. declare module BABYLON {
  25772. /** @hidden */
  25773. export var logDepthDeclaration: {
  25774. name: string;
  25775. shader: string;
  25776. };
  25777. }
  25778. declare module BABYLON {
  25779. /** @hidden */
  25780. export var bumpFragment: {
  25781. name: string;
  25782. shader: string;
  25783. };
  25784. }
  25785. declare module BABYLON {
  25786. /** @hidden */
  25787. export var depthPrePass: {
  25788. name: string;
  25789. shader: string;
  25790. };
  25791. }
  25792. declare module BABYLON {
  25793. /** @hidden */
  25794. export var lightFragment: {
  25795. name: string;
  25796. shader: string;
  25797. };
  25798. }
  25799. declare module BABYLON {
  25800. /** @hidden */
  25801. export var logDepthFragment: {
  25802. name: string;
  25803. shader: string;
  25804. };
  25805. }
  25806. declare module BABYLON {
  25807. /** @hidden */
  25808. export var defaultPixelShader: {
  25809. name: string;
  25810. shader: string;
  25811. };
  25812. }
  25813. declare module BABYLON {
  25814. /** @hidden */
  25815. export var defaultVertexDeclaration: {
  25816. name: string;
  25817. shader: string;
  25818. };
  25819. }
  25820. declare module BABYLON {
  25821. /** @hidden */
  25822. export var bumpVertexDeclaration: {
  25823. name: string;
  25824. shader: string;
  25825. };
  25826. }
  25827. declare module BABYLON {
  25828. /** @hidden */
  25829. export var bumpVertex: {
  25830. name: string;
  25831. shader: string;
  25832. };
  25833. }
  25834. declare module BABYLON {
  25835. /** @hidden */
  25836. export var fogVertex: {
  25837. name: string;
  25838. shader: string;
  25839. };
  25840. }
  25841. declare module BABYLON {
  25842. /** @hidden */
  25843. export var shadowsVertex: {
  25844. name: string;
  25845. shader: string;
  25846. };
  25847. }
  25848. declare module BABYLON {
  25849. /** @hidden */
  25850. export var pointCloudVertex: {
  25851. name: string;
  25852. shader: string;
  25853. };
  25854. }
  25855. declare module BABYLON {
  25856. /** @hidden */
  25857. export var logDepthVertex: {
  25858. name: string;
  25859. shader: string;
  25860. };
  25861. }
  25862. declare module BABYLON {
  25863. /** @hidden */
  25864. export var defaultVertexShader: {
  25865. name: string;
  25866. shader: string;
  25867. };
  25868. }
  25869. declare module BABYLON {
  25870. /** @hidden */
  25871. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  25872. MAINUV1: boolean;
  25873. MAINUV2: boolean;
  25874. DIFFUSE: boolean;
  25875. DIFFUSEDIRECTUV: number;
  25876. AMBIENT: boolean;
  25877. AMBIENTDIRECTUV: number;
  25878. OPACITY: boolean;
  25879. OPACITYDIRECTUV: number;
  25880. OPACITYRGB: boolean;
  25881. REFLECTION: boolean;
  25882. EMISSIVE: boolean;
  25883. EMISSIVEDIRECTUV: number;
  25884. SPECULAR: boolean;
  25885. SPECULARDIRECTUV: number;
  25886. BUMP: boolean;
  25887. BUMPDIRECTUV: number;
  25888. PARALLAX: boolean;
  25889. PARALLAXOCCLUSION: boolean;
  25890. SPECULAROVERALPHA: boolean;
  25891. CLIPPLANE: boolean;
  25892. CLIPPLANE2: boolean;
  25893. CLIPPLANE3: boolean;
  25894. CLIPPLANE4: boolean;
  25895. ALPHATEST: boolean;
  25896. DEPTHPREPASS: boolean;
  25897. ALPHAFROMDIFFUSE: boolean;
  25898. POINTSIZE: boolean;
  25899. FOG: boolean;
  25900. SPECULARTERM: boolean;
  25901. DIFFUSEFRESNEL: boolean;
  25902. OPACITYFRESNEL: boolean;
  25903. REFLECTIONFRESNEL: boolean;
  25904. REFRACTIONFRESNEL: boolean;
  25905. EMISSIVEFRESNEL: boolean;
  25906. FRESNEL: boolean;
  25907. NORMAL: boolean;
  25908. UV1: boolean;
  25909. UV2: boolean;
  25910. VERTEXCOLOR: boolean;
  25911. VERTEXALPHA: boolean;
  25912. NUM_BONE_INFLUENCERS: number;
  25913. BonesPerMesh: number;
  25914. BONETEXTURE: boolean;
  25915. INSTANCES: boolean;
  25916. GLOSSINESS: boolean;
  25917. ROUGHNESS: boolean;
  25918. EMISSIVEASILLUMINATION: boolean;
  25919. LINKEMISSIVEWITHDIFFUSE: boolean;
  25920. REFLECTIONFRESNELFROMSPECULAR: boolean;
  25921. LIGHTMAP: boolean;
  25922. LIGHTMAPDIRECTUV: number;
  25923. OBJECTSPACE_NORMALMAP: boolean;
  25924. USELIGHTMAPASSHADOWMAP: boolean;
  25925. REFLECTIONMAP_3D: boolean;
  25926. REFLECTIONMAP_SPHERICAL: boolean;
  25927. REFLECTIONMAP_PLANAR: boolean;
  25928. REFLECTIONMAP_CUBIC: boolean;
  25929. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  25930. REFLECTIONMAP_PROJECTION: boolean;
  25931. REFLECTIONMAP_SKYBOX: boolean;
  25932. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  25933. REFLECTIONMAP_EXPLICIT: boolean;
  25934. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  25935. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  25936. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  25937. INVERTCUBICMAP: boolean;
  25938. LOGARITHMICDEPTH: boolean;
  25939. REFRACTION: boolean;
  25940. REFRACTIONMAP_3D: boolean;
  25941. REFLECTIONOVERALPHA: boolean;
  25942. TWOSIDEDLIGHTING: boolean;
  25943. SHADOWFLOAT: boolean;
  25944. MORPHTARGETS: boolean;
  25945. MORPHTARGETS_NORMAL: boolean;
  25946. MORPHTARGETS_TANGENT: boolean;
  25947. MORPHTARGETS_UV: boolean;
  25948. NUM_MORPH_INFLUENCERS: number;
  25949. NONUNIFORMSCALING: boolean;
  25950. PREMULTIPLYALPHA: boolean;
  25951. IMAGEPROCESSING: boolean;
  25952. VIGNETTE: boolean;
  25953. VIGNETTEBLENDMODEMULTIPLY: boolean;
  25954. VIGNETTEBLENDMODEOPAQUE: boolean;
  25955. TONEMAPPING: boolean;
  25956. TONEMAPPING_ACES: boolean;
  25957. CONTRAST: boolean;
  25958. COLORCURVES: boolean;
  25959. COLORGRADING: boolean;
  25960. COLORGRADING3D: boolean;
  25961. SAMPLER3DGREENDEPTH: boolean;
  25962. SAMPLER3DBGRMAP: boolean;
  25963. IMAGEPROCESSINGPOSTPROCESS: boolean;
  25964. MULTIVIEW: boolean;
  25965. /**
  25966. * If the reflection texture on this material is in linear color space
  25967. * @hidden
  25968. */
  25969. IS_REFLECTION_LINEAR: boolean;
  25970. /**
  25971. * If the refraction texture on this material is in linear color space
  25972. * @hidden
  25973. */
  25974. IS_REFRACTION_LINEAR: boolean;
  25975. EXPOSURE: boolean;
  25976. constructor();
  25977. setReflectionMode(modeToEnable: string): void;
  25978. }
  25979. /**
  25980. * This is the default material used in Babylon. It is the best trade off between quality
  25981. * and performances.
  25982. * @see http://doc.babylonjs.com/babylon101/materials
  25983. */
  25984. export class StandardMaterial extends PushMaterial {
  25985. private _diffuseTexture;
  25986. /**
  25987. * The basic texture of the material as viewed under a light.
  25988. */
  25989. diffuseTexture: Nullable<BaseTexture>;
  25990. private _ambientTexture;
  25991. /**
  25992. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  25993. */
  25994. ambientTexture: Nullable<BaseTexture>;
  25995. private _opacityTexture;
  25996. /**
  25997. * Define the transparency of the material from a texture.
  25998. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  25999. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26000. */
  26001. opacityTexture: Nullable<BaseTexture>;
  26002. private _reflectionTexture;
  26003. /**
  26004. * Define the texture used to display the reflection.
  26005. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26006. */
  26007. reflectionTexture: Nullable<BaseTexture>;
  26008. private _emissiveTexture;
  26009. /**
  26010. * Define texture of the material as if self lit.
  26011. * This will be mixed in the final result even in the absence of light.
  26012. */
  26013. emissiveTexture: Nullable<BaseTexture>;
  26014. private _specularTexture;
  26015. /**
  26016. * Define how the color and intensity of the highlight given by the light in the material.
  26017. */
  26018. specularTexture: Nullable<BaseTexture>;
  26019. private _bumpTexture;
  26020. /**
  26021. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26022. * 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.
  26023. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26024. */
  26025. bumpTexture: Nullable<BaseTexture>;
  26026. private _lightmapTexture;
  26027. /**
  26028. * Complex lighting can be computationally expensive to compute at runtime.
  26029. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26030. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26031. */
  26032. lightmapTexture: Nullable<BaseTexture>;
  26033. private _refractionTexture;
  26034. /**
  26035. * Define the texture used to display the refraction.
  26036. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26037. */
  26038. refractionTexture: Nullable<BaseTexture>;
  26039. /**
  26040. * The color of the material lit by the environmental background lighting.
  26041. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26042. */
  26043. ambientColor: Color3;
  26044. /**
  26045. * The basic color of the material as viewed under a light.
  26046. */
  26047. diffuseColor: Color3;
  26048. /**
  26049. * Define how the color and intensity of the highlight given by the light in the material.
  26050. */
  26051. specularColor: Color3;
  26052. /**
  26053. * Define the color of the material as if self lit.
  26054. * This will be mixed in the final result even in the absence of light.
  26055. */
  26056. emissiveColor: Color3;
  26057. /**
  26058. * Defines how sharp are the highlights in the material.
  26059. * The bigger the value the sharper giving a more glossy feeling to the result.
  26060. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26061. */
  26062. specularPower: number;
  26063. private _useAlphaFromDiffuseTexture;
  26064. /**
  26065. * Does the transparency come from the diffuse texture alpha channel.
  26066. */
  26067. useAlphaFromDiffuseTexture: boolean;
  26068. private _useEmissiveAsIllumination;
  26069. /**
  26070. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26071. */
  26072. useEmissiveAsIllumination: boolean;
  26073. private _linkEmissiveWithDiffuse;
  26074. /**
  26075. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26076. * the emissive level when the final color is close to one.
  26077. */
  26078. linkEmissiveWithDiffuse: boolean;
  26079. private _useSpecularOverAlpha;
  26080. /**
  26081. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26082. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26083. */
  26084. useSpecularOverAlpha: boolean;
  26085. private _useReflectionOverAlpha;
  26086. /**
  26087. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26088. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26089. */
  26090. useReflectionOverAlpha: boolean;
  26091. private _disableLighting;
  26092. /**
  26093. * Does lights from the scene impacts this material.
  26094. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26095. */
  26096. disableLighting: boolean;
  26097. private _useObjectSpaceNormalMap;
  26098. /**
  26099. * Allows using an object space normal map (instead of tangent space).
  26100. */
  26101. useObjectSpaceNormalMap: boolean;
  26102. private _useParallax;
  26103. /**
  26104. * Is parallax enabled or not.
  26105. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26106. */
  26107. useParallax: boolean;
  26108. private _useParallaxOcclusion;
  26109. /**
  26110. * Is parallax occlusion enabled or not.
  26111. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26112. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26113. */
  26114. useParallaxOcclusion: boolean;
  26115. /**
  26116. * 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.
  26117. */
  26118. parallaxScaleBias: number;
  26119. private _roughness;
  26120. /**
  26121. * Helps to define how blurry the reflections should appears in the material.
  26122. */
  26123. roughness: number;
  26124. /**
  26125. * In case of refraction, define the value of the index of refraction.
  26126. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26127. */
  26128. indexOfRefraction: number;
  26129. /**
  26130. * Invert the refraction texture alongside the y axis.
  26131. * It can be useful with procedural textures or probe for instance.
  26132. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26133. */
  26134. invertRefractionY: boolean;
  26135. /**
  26136. * Defines the alpha limits in alpha test mode.
  26137. */
  26138. alphaCutOff: number;
  26139. private _useLightmapAsShadowmap;
  26140. /**
  26141. * In case of light mapping, define whether the map contains light or shadow informations.
  26142. */
  26143. useLightmapAsShadowmap: boolean;
  26144. private _diffuseFresnelParameters;
  26145. /**
  26146. * Define the diffuse fresnel parameters of the material.
  26147. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26148. */
  26149. diffuseFresnelParameters: FresnelParameters;
  26150. private _opacityFresnelParameters;
  26151. /**
  26152. * Define the opacity fresnel parameters of the material.
  26153. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26154. */
  26155. opacityFresnelParameters: FresnelParameters;
  26156. private _reflectionFresnelParameters;
  26157. /**
  26158. * Define the reflection fresnel parameters of the material.
  26159. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26160. */
  26161. reflectionFresnelParameters: FresnelParameters;
  26162. private _refractionFresnelParameters;
  26163. /**
  26164. * Define the refraction fresnel parameters of the material.
  26165. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26166. */
  26167. refractionFresnelParameters: FresnelParameters;
  26168. private _emissiveFresnelParameters;
  26169. /**
  26170. * Define the emissive fresnel parameters of the material.
  26171. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26172. */
  26173. emissiveFresnelParameters: FresnelParameters;
  26174. private _useReflectionFresnelFromSpecular;
  26175. /**
  26176. * If true automatically deducts the fresnels values from the material specularity.
  26177. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26178. */
  26179. useReflectionFresnelFromSpecular: boolean;
  26180. private _useGlossinessFromSpecularMapAlpha;
  26181. /**
  26182. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26183. */
  26184. useGlossinessFromSpecularMapAlpha: boolean;
  26185. private _maxSimultaneousLights;
  26186. /**
  26187. * Defines the maximum number of lights that can be used in the material
  26188. */
  26189. maxSimultaneousLights: number;
  26190. private _invertNormalMapX;
  26191. /**
  26192. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26193. */
  26194. invertNormalMapX: boolean;
  26195. private _invertNormalMapY;
  26196. /**
  26197. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26198. */
  26199. invertNormalMapY: boolean;
  26200. private _twoSidedLighting;
  26201. /**
  26202. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26203. */
  26204. twoSidedLighting: boolean;
  26205. /**
  26206. * Default configuration related to image processing available in the standard Material.
  26207. */
  26208. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26209. /**
  26210. * Gets the image processing configuration used either in this material.
  26211. */
  26212. /**
  26213. * Sets the Default image processing configuration used either in the this material.
  26214. *
  26215. * If sets to null, the scene one is in use.
  26216. */
  26217. imageProcessingConfiguration: ImageProcessingConfiguration;
  26218. /**
  26219. * Keep track of the image processing observer to allow dispose and replace.
  26220. */
  26221. private _imageProcessingObserver;
  26222. /**
  26223. * Attaches a new image processing configuration to the Standard Material.
  26224. * @param configuration
  26225. */
  26226. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26227. /**
  26228. * Gets wether the color curves effect is enabled.
  26229. */
  26230. /**
  26231. * Sets wether the color curves effect is enabled.
  26232. */
  26233. cameraColorCurvesEnabled: boolean;
  26234. /**
  26235. * Gets wether the color grading effect is enabled.
  26236. */
  26237. /**
  26238. * Gets wether the color grading effect is enabled.
  26239. */
  26240. cameraColorGradingEnabled: boolean;
  26241. /**
  26242. * Gets wether tonemapping is enabled or not.
  26243. */
  26244. /**
  26245. * Sets wether tonemapping is enabled or not
  26246. */
  26247. cameraToneMappingEnabled: boolean;
  26248. /**
  26249. * The camera exposure used on this material.
  26250. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26251. * This corresponds to a photographic exposure.
  26252. */
  26253. /**
  26254. * The camera exposure used on this material.
  26255. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26256. * This corresponds to a photographic exposure.
  26257. */
  26258. cameraExposure: number;
  26259. /**
  26260. * Gets The camera contrast used on this material.
  26261. */
  26262. /**
  26263. * Sets The camera contrast used on this material.
  26264. */
  26265. cameraContrast: number;
  26266. /**
  26267. * Gets the Color Grading 2D Lookup Texture.
  26268. */
  26269. /**
  26270. * Sets the Color Grading 2D Lookup Texture.
  26271. */
  26272. cameraColorGradingTexture: Nullable<BaseTexture>;
  26273. /**
  26274. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26275. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26276. * 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;
  26277. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26278. */
  26279. /**
  26280. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26281. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26282. * 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;
  26283. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26284. */
  26285. cameraColorCurves: Nullable<ColorCurves>;
  26286. /**
  26287. * Custom callback helping to override the default shader used in the material.
  26288. */
  26289. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26290. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26291. protected _worldViewProjectionMatrix: Matrix;
  26292. protected _globalAmbientColor: Color3;
  26293. protected _useLogarithmicDepth: boolean;
  26294. protected _rebuildInParallel: boolean;
  26295. /**
  26296. * Instantiates a new standard material.
  26297. * This is the default material used in Babylon. It is the best trade off between quality
  26298. * and performances.
  26299. * @see http://doc.babylonjs.com/babylon101/materials
  26300. * @param name Define the name of the material in the scene
  26301. * @param scene Define the scene the material belong to
  26302. */
  26303. constructor(name: string, scene: Scene);
  26304. /**
  26305. * Gets a boolean indicating that current material needs to register RTT
  26306. */
  26307. readonly hasRenderTargetTextures: boolean;
  26308. /**
  26309. * Gets the current class name of the material e.g. "StandardMaterial"
  26310. * Mainly use in serialization.
  26311. * @returns the class name
  26312. */
  26313. getClassName(): string;
  26314. /**
  26315. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26316. * You can try switching to logarithmic depth.
  26317. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26318. */
  26319. useLogarithmicDepth: boolean;
  26320. /**
  26321. * Specifies if the material will require alpha blending
  26322. * @returns a boolean specifying if alpha blending is needed
  26323. */
  26324. needAlphaBlending(): boolean;
  26325. /**
  26326. * Specifies if this material should be rendered in alpha test mode
  26327. * @returns a boolean specifying if an alpha test is needed.
  26328. */
  26329. needAlphaTesting(): boolean;
  26330. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26331. /**
  26332. * Get the texture used for alpha test purpose.
  26333. * @returns the diffuse texture in case of the standard material.
  26334. */
  26335. getAlphaTestTexture(): Nullable<BaseTexture>;
  26336. /**
  26337. * Get if the submesh is ready to be used and all its information available.
  26338. * Child classes can use it to update shaders
  26339. * @param mesh defines the mesh to check
  26340. * @param subMesh defines which submesh to check
  26341. * @param useInstances specifies that instances should be used
  26342. * @returns a boolean indicating that the submesh is ready or not
  26343. */
  26344. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26345. /**
  26346. * Builds the material UBO layouts.
  26347. * Used internally during the effect preparation.
  26348. */
  26349. buildUniformLayout(): void;
  26350. /**
  26351. * Unbinds the material from the mesh
  26352. */
  26353. unbind(): void;
  26354. /**
  26355. * Binds the submesh to this material by preparing the effect and shader to draw
  26356. * @param world defines the world transformation matrix
  26357. * @param mesh defines the mesh containing the submesh
  26358. * @param subMesh defines the submesh to bind the material to
  26359. */
  26360. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26361. /**
  26362. * Get the list of animatables in the material.
  26363. * @returns the list of animatables object used in the material
  26364. */
  26365. getAnimatables(): IAnimatable[];
  26366. /**
  26367. * Gets the active textures from the material
  26368. * @returns an array of textures
  26369. */
  26370. getActiveTextures(): BaseTexture[];
  26371. /**
  26372. * Specifies if the material uses a texture
  26373. * @param texture defines the texture to check against the material
  26374. * @returns a boolean specifying if the material uses the texture
  26375. */
  26376. hasTexture(texture: BaseTexture): boolean;
  26377. /**
  26378. * Disposes the material
  26379. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26380. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26381. */
  26382. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26383. /**
  26384. * Makes a duplicate of the material, and gives it a new name
  26385. * @param name defines the new name for the duplicated material
  26386. * @returns the cloned material
  26387. */
  26388. clone(name: string): StandardMaterial;
  26389. /**
  26390. * Serializes this material in a JSON representation
  26391. * @returns the serialized material object
  26392. */
  26393. serialize(): any;
  26394. /**
  26395. * Creates a standard material from parsed material data
  26396. * @param source defines the JSON representation of the material
  26397. * @param scene defines the hosting scene
  26398. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26399. * @returns a new standard material
  26400. */
  26401. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26402. /**
  26403. * Are diffuse textures enabled in the application.
  26404. */
  26405. static DiffuseTextureEnabled: boolean;
  26406. /**
  26407. * Are ambient textures enabled in the application.
  26408. */
  26409. static AmbientTextureEnabled: boolean;
  26410. /**
  26411. * Are opacity textures enabled in the application.
  26412. */
  26413. static OpacityTextureEnabled: boolean;
  26414. /**
  26415. * Are reflection textures enabled in the application.
  26416. */
  26417. static ReflectionTextureEnabled: boolean;
  26418. /**
  26419. * Are emissive textures enabled in the application.
  26420. */
  26421. static EmissiveTextureEnabled: boolean;
  26422. /**
  26423. * Are specular textures enabled in the application.
  26424. */
  26425. static SpecularTextureEnabled: boolean;
  26426. /**
  26427. * Are bump textures enabled in the application.
  26428. */
  26429. static BumpTextureEnabled: boolean;
  26430. /**
  26431. * Are lightmap textures enabled in the application.
  26432. */
  26433. static LightmapTextureEnabled: boolean;
  26434. /**
  26435. * Are refraction textures enabled in the application.
  26436. */
  26437. static RefractionTextureEnabled: boolean;
  26438. /**
  26439. * Are color grading textures enabled in the application.
  26440. */
  26441. static ColorGradingTextureEnabled: boolean;
  26442. /**
  26443. * Are fresnels enabled in the application.
  26444. */
  26445. static FresnelEnabled: boolean;
  26446. }
  26447. }
  26448. declare module BABYLON {
  26449. /**
  26450. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26451. *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.
  26452. * The SPS is also a particle system. It provides some methods to manage the particles.
  26453. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26454. *
  26455. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26456. */
  26457. export class SolidParticleSystem implements IDisposable {
  26458. /**
  26459. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26460. * Example : var p = SPS.particles[i];
  26461. */
  26462. particles: SolidParticle[];
  26463. /**
  26464. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26465. */
  26466. nbParticles: number;
  26467. /**
  26468. * If the particles must ever face the camera (default false). Useful for planar particles.
  26469. */
  26470. billboard: boolean;
  26471. /**
  26472. * Recompute normals when adding a shape
  26473. */
  26474. recomputeNormals: boolean;
  26475. /**
  26476. * This a counter ofr your own usage. It's not set by any SPS functions.
  26477. */
  26478. counter: number;
  26479. /**
  26480. * The SPS name. This name is also given to the underlying mesh.
  26481. */
  26482. name: string;
  26483. /**
  26484. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26485. */
  26486. mesh: Mesh;
  26487. /**
  26488. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26489. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26490. */
  26491. vars: any;
  26492. /**
  26493. * This array is populated when the SPS is set as 'pickable'.
  26494. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26495. * Each element of this array is an object `{idx: int, faceId: int}`.
  26496. * `idx` is the picked particle index in the `SPS.particles` array
  26497. * `faceId` is the picked face index counted within this particle.
  26498. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26499. */
  26500. pickedParticles: {
  26501. idx: number;
  26502. faceId: number;
  26503. }[];
  26504. /**
  26505. * This array is populated when `enableDepthSort` is set to true.
  26506. * Each element of this array is an instance of the class DepthSortedParticle.
  26507. */
  26508. depthSortedParticles: DepthSortedParticle[];
  26509. /**
  26510. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26511. * @hidden
  26512. */
  26513. _bSphereOnly: boolean;
  26514. /**
  26515. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26516. * @hidden
  26517. */
  26518. _bSphereRadiusFactor: number;
  26519. private _scene;
  26520. private _positions;
  26521. private _indices;
  26522. private _normals;
  26523. private _colors;
  26524. private _uvs;
  26525. private _indices32;
  26526. private _positions32;
  26527. private _normals32;
  26528. private _fixedNormal32;
  26529. private _colors32;
  26530. private _uvs32;
  26531. private _index;
  26532. private _updatable;
  26533. private _pickable;
  26534. private _isVisibilityBoxLocked;
  26535. private _alwaysVisible;
  26536. private _depthSort;
  26537. private _expandable;
  26538. private _shapeCounter;
  26539. private _copy;
  26540. private _color;
  26541. private _computeParticleColor;
  26542. private _computeParticleTexture;
  26543. private _computeParticleRotation;
  26544. private _computeParticleVertex;
  26545. private _computeBoundingBox;
  26546. private _depthSortParticles;
  26547. private _camera;
  26548. private _mustUnrotateFixedNormals;
  26549. private _particlesIntersect;
  26550. private _needs32Bits;
  26551. private _isNotBuilt;
  26552. private _lastParticleId;
  26553. private _idxOfId;
  26554. private _multimaterialEnabled;
  26555. private _useModelMaterial;
  26556. private _indicesByMaterial;
  26557. private _materialIndexes;
  26558. private _depthSortFunction;
  26559. private _materialSortFunction;
  26560. private _materials;
  26561. private _multimaterial;
  26562. private _materialIndexesById;
  26563. private _defaultMaterial;
  26564. private _autoUpdateSubMeshes;
  26565. /**
  26566. * Creates a SPS (Solid Particle System) object.
  26567. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26568. * @param scene (Scene) is the scene in which the SPS is added.
  26569. * @param options defines the options of the sps e.g.
  26570. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26571. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26572. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26573. * * 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.
  26574. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  26575. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26576. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26577. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26578. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26579. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26580. */
  26581. constructor(name: string, scene: Scene, options?: {
  26582. updatable?: boolean;
  26583. isPickable?: boolean;
  26584. enableDepthSort?: boolean;
  26585. particleIntersection?: boolean;
  26586. boundingSphereOnly?: boolean;
  26587. bSphereRadiusFactor?: number;
  26588. expandable?: boolean;
  26589. useModelMaterial?: boolean;
  26590. enableMultiMaterial?: boolean;
  26591. });
  26592. /**
  26593. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26594. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26595. * @returns the created mesh
  26596. */
  26597. buildMesh(): Mesh;
  26598. /**
  26599. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26600. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26601. * Thus the particles generated from `digest()` have their property `position` set yet.
  26602. * @param mesh ( Mesh ) is the mesh to be digested
  26603. * @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
  26604. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26605. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26606. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26607. * @returns the current SPS
  26608. */
  26609. digest(mesh: Mesh, options?: {
  26610. facetNb?: number;
  26611. number?: number;
  26612. delta?: number;
  26613. storage?: [];
  26614. }): SolidParticleSystem;
  26615. /**
  26616. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26617. * @hidden
  26618. */
  26619. private _unrotateFixedNormals;
  26620. /**
  26621. * Resets the temporary working copy particle
  26622. * @hidden
  26623. */
  26624. private _resetCopy;
  26625. /**
  26626. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26627. * @param p the current index in the positions array to be updated
  26628. * @param ind the current index in the indices array
  26629. * @param shape a Vector3 array, the shape geometry
  26630. * @param positions the positions array to be updated
  26631. * @param meshInd the shape indices array
  26632. * @param indices the indices array to be updated
  26633. * @param meshUV the shape uv array
  26634. * @param uvs the uv array to be updated
  26635. * @param meshCol the shape color array
  26636. * @param colors the color array to be updated
  26637. * @param meshNor the shape normals array
  26638. * @param normals the normals array to be updated
  26639. * @param idx the particle index
  26640. * @param idxInShape the particle index in its shape
  26641. * @param options the addShape() method passed options
  26642. * @model the particle model
  26643. * @hidden
  26644. */
  26645. private _meshBuilder;
  26646. /**
  26647. * Returns a shape Vector3 array from positions float array
  26648. * @param positions float array
  26649. * @returns a vector3 array
  26650. * @hidden
  26651. */
  26652. private _posToShape;
  26653. /**
  26654. * Returns a shapeUV array from a float uvs (array deep copy)
  26655. * @param uvs as a float array
  26656. * @returns a shapeUV array
  26657. * @hidden
  26658. */
  26659. private _uvsToShapeUV;
  26660. /**
  26661. * Adds a new particle object in the particles array
  26662. * @param idx particle index in particles array
  26663. * @param id particle id
  26664. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26665. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26666. * @param model particle ModelShape object
  26667. * @param shapeId model shape identifier
  26668. * @param idxInShape index of the particle in the current model
  26669. * @param bInfo model bounding info object
  26670. * @param storage target storage array, if any
  26671. * @hidden
  26672. */
  26673. private _addParticle;
  26674. /**
  26675. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26676. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26677. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26678. * @param nb (positive integer) the number of particles to be created from this model
  26679. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26680. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26681. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26682. * @returns the number of shapes in the system
  26683. */
  26684. addShape(mesh: Mesh, nb: number, options?: {
  26685. positionFunction?: any;
  26686. vertexFunction?: any;
  26687. storage?: [];
  26688. }): number;
  26689. /**
  26690. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  26691. * @hidden
  26692. */
  26693. private _rebuildParticle;
  26694. /**
  26695. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26696. * @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.
  26697. * @returns the SPS.
  26698. */
  26699. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26700. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26701. * Returns an array with the removed particles.
  26702. * 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.
  26703. * The SPS can't be empty so at least one particle needs to remain in place.
  26704. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26705. * @param start index of the first particle to remove
  26706. * @param end index of the last particle to remove (included)
  26707. * @returns an array populated with the removed particles
  26708. */
  26709. removeParticles(start: number, end: number): SolidParticle[];
  26710. /**
  26711. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  26712. * @param solidParticleArray an array populated with Solid Particles objects
  26713. * @returns the SPS
  26714. */
  26715. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  26716. /**
  26717. * Creates a new particle and modifies the SPS mesh geometry :
  26718. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  26719. * - calls _addParticle() to populate the particle array
  26720. * factorized code from addShape() and insertParticlesFromArray()
  26721. * @param idx particle index in the particles array
  26722. * @param i particle index in its shape
  26723. * @param modelShape particle ModelShape object
  26724. * @param shape shape vertex array
  26725. * @param meshInd shape indices array
  26726. * @param meshUV shape uv array
  26727. * @param meshCol shape color array
  26728. * @param meshNor shape normals array
  26729. * @param bbInfo shape bounding info
  26730. * @param storage target particle storage
  26731. * @options addShape() passed options
  26732. * @hidden
  26733. */
  26734. private _insertNewParticle;
  26735. /**
  26736. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26737. * This method calls `updateParticle()` for each particle of the SPS.
  26738. * For an animated SPS, it is usually called within the render loop.
  26739. * 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.
  26740. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26741. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26742. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26743. * @returns the SPS.
  26744. */
  26745. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26746. /**
  26747. * Disposes the SPS.
  26748. */
  26749. dispose(): void;
  26750. /**
  26751. * Returns a SolidParticle object from its identifier : particle.id
  26752. * @param id (integer) the particle Id
  26753. * @returns the searched particle or null if not found in the SPS.
  26754. */
  26755. getParticleById(id: number): Nullable<SolidParticle>;
  26756. /**
  26757. * Returns a new array populated with the particles having the passed shapeId.
  26758. * @param shapeId (integer) the shape identifier
  26759. * @returns a new solid particle array
  26760. */
  26761. getParticlesByShapeId(shapeId: number): SolidParticle[];
  26762. /**
  26763. * Populates the passed array "ref" with the particles having the passed shapeId.
  26764. * @param shapeId the shape identifier
  26765. * @returns the SPS
  26766. * @param ref
  26767. */
  26768. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  26769. /**
  26770. * Computes the required SubMeshes according the materials assigned to the particles.
  26771. * @returns the solid particle system.
  26772. * Does nothing if called before the SPS mesh is built.
  26773. */
  26774. computeSubMeshes(): SolidParticleSystem;
  26775. /**
  26776. * Sorts the solid particles by material when MultiMaterial is enabled.
  26777. * Updates the indices32 array.
  26778. * Updates the indicesByMaterial array.
  26779. * Updates the mesh indices array.
  26780. * @returns the SPS
  26781. * @hidden
  26782. */
  26783. private _sortParticlesByMaterial;
  26784. /**
  26785. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  26786. * @hidden
  26787. */
  26788. private _setMaterialIndexesById;
  26789. /**
  26790. * Returns an array with unique values of Materials from the passed array
  26791. * @param array the material array to be checked and filtered
  26792. * @hidden
  26793. */
  26794. private _filterUniqueMaterialId;
  26795. /**
  26796. * Sets a new Standard Material as _defaultMaterial if not already set.
  26797. * @hidden
  26798. */
  26799. private _setDefaultMaterial;
  26800. /**
  26801. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26802. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26803. * @returns the SPS.
  26804. */
  26805. refreshVisibleSize(): SolidParticleSystem;
  26806. /**
  26807. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26808. * @param size the size (float) of the visibility box
  26809. * note : this doesn't lock the SPS mesh bounding box.
  26810. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26811. */
  26812. setVisibilityBox(size: number): void;
  26813. /**
  26814. * Gets whether the SPS as always visible or not
  26815. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26816. */
  26817. /**
  26818. * Sets the SPS as always visible or not
  26819. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26820. */
  26821. isAlwaysVisible: boolean;
  26822. /**
  26823. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26824. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26825. */
  26826. /**
  26827. * Gets if 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. isVisibilityBoxLocked: boolean;
  26831. /**
  26832. * Tells to `setParticles()` to compute the particle rotations or not.
  26833. * Default value : true. The SPS is faster when it's set to false.
  26834. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26835. */
  26836. /**
  26837. * Gets if `setParticles()` computes the particle rotations or not.
  26838. * Default value : true. The SPS is faster when it's set to false.
  26839. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26840. */
  26841. computeParticleRotation: boolean;
  26842. /**
  26843. * Tells to `setParticles()` to compute the particle colors or not.
  26844. * Default value : true. The SPS is faster when it's set to false.
  26845. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26846. */
  26847. /**
  26848. * Gets if `setParticles()` computes the particle colors or not.
  26849. * Default value : true. The SPS is faster when it's set to false.
  26850. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26851. */
  26852. computeParticleColor: boolean;
  26853. /**
  26854. * Gets if `setParticles()` computes the particle textures or not.
  26855. * Default value : true. The SPS is faster when it's set to false.
  26856. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26857. */
  26858. computeParticleTexture: boolean;
  26859. /**
  26860. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26861. * Default value : false. The SPS is faster when it's set to false.
  26862. * Note : the particle custom vertex positions aren't stored values.
  26863. */
  26864. /**
  26865. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26866. * Default value : false. The SPS is faster when it's set to false.
  26867. * Note : the particle custom vertex positions aren't stored values.
  26868. */
  26869. computeParticleVertex: boolean;
  26870. /**
  26871. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26872. */
  26873. /**
  26874. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26875. */
  26876. computeBoundingBox: boolean;
  26877. /**
  26878. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26879. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26880. * Default : `true`
  26881. */
  26882. /**
  26883. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26884. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26885. * Default : `true`
  26886. */
  26887. depthSortParticles: boolean;
  26888. /**
  26889. * Gets if the SPS is created as expandable at construction time.
  26890. * Default : `false`
  26891. */
  26892. readonly expandable: boolean;
  26893. /**
  26894. * Gets if the SPS supports the Multi Materials
  26895. */
  26896. readonly multimaterialEnabled: boolean;
  26897. /**
  26898. * Gets if the SPS uses the model materials for its own multimaterial.
  26899. */
  26900. readonly useModelMaterial: boolean;
  26901. /**
  26902. * The SPS used material array.
  26903. */
  26904. readonly materials: Material[];
  26905. /**
  26906. * Sets the SPS MultiMaterial from the passed materials.
  26907. * Note : the passed array is internally copied and not used then by reference.
  26908. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  26909. */
  26910. setMultiMaterial(materials: Material[]): void;
  26911. /**
  26912. * The SPS computed multimaterial object
  26913. */
  26914. multimaterial: MultiMaterial;
  26915. /**
  26916. * If the subMeshes must be updated on the next call to setParticles()
  26917. */
  26918. autoUpdateSubMeshes: boolean;
  26919. /**
  26920. * This function does nothing. It may be overwritten to set all the particle first values.
  26921. * The SPS doesn't call this function, you may have to call it by your own.
  26922. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26923. */
  26924. initParticles(): void;
  26925. /**
  26926. * This function does nothing. It may be overwritten to recycle a particle.
  26927. * The SPS doesn't call this function, you may have to call it by your own.
  26928. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26929. * @param particle The particle to recycle
  26930. * @returns the recycled particle
  26931. */
  26932. recycleParticle(particle: SolidParticle): SolidParticle;
  26933. /**
  26934. * Updates a particle : this function should be overwritten by the user.
  26935. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26936. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26937. * @example : just set a particle position or velocity and recycle conditions
  26938. * @param particle The particle to update
  26939. * @returns the updated particle
  26940. */
  26941. updateParticle(particle: SolidParticle): SolidParticle;
  26942. /**
  26943. * Updates a vertex of a particle : it can be overwritten by the user.
  26944. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26945. * @param particle the current particle
  26946. * @param vertex the current index of the current particle
  26947. * @param pt the index of the current vertex in the particle shape
  26948. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26949. * @example : just set a vertex particle position
  26950. * @returns the updated vertex
  26951. */
  26952. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26953. /**
  26954. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26955. * This does nothing and may be overwritten by the user.
  26956. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26957. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26958. * @param update the boolean update value actually passed to setParticles()
  26959. */
  26960. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26961. /**
  26962. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26963. * This will be passed three parameters.
  26964. * This does nothing and may be overwritten by the user.
  26965. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26966. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26967. * @param update the boolean update value actually passed to setParticles()
  26968. */
  26969. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26970. }
  26971. }
  26972. declare module BABYLON {
  26973. /**
  26974. * Represents one particle of a solid particle system.
  26975. */
  26976. export class SolidParticle {
  26977. /**
  26978. * particle global index
  26979. */
  26980. idx: number;
  26981. /**
  26982. * particle identifier
  26983. */
  26984. id: number;
  26985. /**
  26986. * The color of the particle
  26987. */
  26988. color: Nullable<Color4>;
  26989. /**
  26990. * The world space position of the particle.
  26991. */
  26992. position: Vector3;
  26993. /**
  26994. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26995. */
  26996. rotation: Vector3;
  26997. /**
  26998. * The world space rotation quaternion of the particle.
  26999. */
  27000. rotationQuaternion: Nullable<Quaternion>;
  27001. /**
  27002. * The scaling of the particle.
  27003. */
  27004. scaling: Vector3;
  27005. /**
  27006. * The uvs of the particle.
  27007. */
  27008. uvs: Vector4;
  27009. /**
  27010. * The current speed of the particle.
  27011. */
  27012. velocity: Vector3;
  27013. /**
  27014. * The pivot point in the particle local space.
  27015. */
  27016. pivot: Vector3;
  27017. /**
  27018. * Must the particle be translated from its pivot point in its local space ?
  27019. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27020. * Default : false
  27021. */
  27022. translateFromPivot: boolean;
  27023. /**
  27024. * Is the particle active or not ?
  27025. */
  27026. alive: boolean;
  27027. /**
  27028. * Is the particle visible or not ?
  27029. */
  27030. isVisible: boolean;
  27031. /**
  27032. * Index of this particle in the global "positions" array (Internal use)
  27033. * @hidden
  27034. */
  27035. _pos: number;
  27036. /**
  27037. * @hidden Index of this particle in the global "indices" array (Internal use)
  27038. */
  27039. _ind: number;
  27040. /**
  27041. * @hidden ModelShape of this particle (Internal use)
  27042. */
  27043. _model: ModelShape;
  27044. /**
  27045. * ModelShape id of this particle
  27046. */
  27047. shapeId: number;
  27048. /**
  27049. * Index of the particle in its shape id
  27050. */
  27051. idxInShape: number;
  27052. /**
  27053. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27054. */
  27055. _modelBoundingInfo: BoundingInfo;
  27056. /**
  27057. * @hidden Particle BoundingInfo object (Internal use)
  27058. */
  27059. _boundingInfo: BoundingInfo;
  27060. /**
  27061. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27062. */
  27063. _sps: SolidParticleSystem;
  27064. /**
  27065. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27066. */
  27067. _stillInvisible: boolean;
  27068. /**
  27069. * @hidden Last computed particle rotation matrix
  27070. */
  27071. _rotationMatrix: number[];
  27072. /**
  27073. * Parent particle Id, if any.
  27074. * Default null.
  27075. */
  27076. parentId: Nullable<number>;
  27077. /**
  27078. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27079. */
  27080. materialIndex: Nullable<number>;
  27081. /**
  27082. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27083. * The possible values are :
  27084. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27085. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27086. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27087. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27088. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27089. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27090. * */
  27091. cullingStrategy: number;
  27092. /**
  27093. * @hidden Internal global position in the SPS.
  27094. */
  27095. _globalPosition: Vector3;
  27096. /**
  27097. * Creates a Solid Particle object.
  27098. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27099. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27100. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27101. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27102. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27103. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27104. * @param shapeId (integer) is the model shape identifier in the SPS.
  27105. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27106. * @param sps defines the sps it is associated to
  27107. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27108. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27109. */
  27110. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27111. /**
  27112. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27113. * @param target the particle target
  27114. * @returns the current particle
  27115. */
  27116. copyToRef(target: SolidParticle): SolidParticle;
  27117. /**
  27118. * Legacy support, changed scale to scaling
  27119. */
  27120. /**
  27121. * Legacy support, changed scale to scaling
  27122. */
  27123. scale: Vector3;
  27124. /**
  27125. * Legacy support, changed quaternion to rotationQuaternion
  27126. */
  27127. /**
  27128. * Legacy support, changed quaternion to rotationQuaternion
  27129. */
  27130. quaternion: Nullable<Quaternion>;
  27131. /**
  27132. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27133. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27134. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27135. * @returns true if it intersects
  27136. */
  27137. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27138. /**
  27139. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27140. * A particle is in the frustum if its bounding box intersects the frustum
  27141. * @param frustumPlanes defines the frustum to test
  27142. * @returns true if the particle is in the frustum planes
  27143. */
  27144. isInFrustum(frustumPlanes: Plane[]): boolean;
  27145. /**
  27146. * get the rotation matrix of the particle
  27147. * @hidden
  27148. */
  27149. getRotationMatrix(m: Matrix): void;
  27150. }
  27151. /**
  27152. * Represents the shape of the model used by one particle of a solid particle system.
  27153. * SPS internal tool, don't use it manually.
  27154. */
  27155. export class ModelShape {
  27156. /**
  27157. * The shape id
  27158. * @hidden
  27159. */
  27160. shapeID: number;
  27161. /**
  27162. * flat array of model positions (internal use)
  27163. * @hidden
  27164. */
  27165. _shape: Vector3[];
  27166. /**
  27167. * flat array of model UVs (internal use)
  27168. * @hidden
  27169. */
  27170. _shapeUV: number[];
  27171. /**
  27172. * color array of the model
  27173. * @hidden
  27174. */
  27175. _shapeColors: number[];
  27176. /**
  27177. * indices array of the model
  27178. * @hidden
  27179. */
  27180. _indices: number[];
  27181. /**
  27182. * normals array of the model
  27183. * @hidden
  27184. */
  27185. _normals: number[];
  27186. /**
  27187. * length of the shape in the model indices array (internal use)
  27188. * @hidden
  27189. */
  27190. _indicesLength: number;
  27191. /**
  27192. * Custom position function (internal use)
  27193. * @hidden
  27194. */
  27195. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27196. /**
  27197. * Custom vertex function (internal use)
  27198. * @hidden
  27199. */
  27200. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27201. /**
  27202. * Model material (internal use)
  27203. * @hidden
  27204. */
  27205. _material: Nullable<Material>;
  27206. /**
  27207. * 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.
  27208. * SPS internal tool, don't use it manually.
  27209. * @hidden
  27210. */
  27211. 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>);
  27212. }
  27213. /**
  27214. * Represents a Depth Sorted Particle in the solid particle system.
  27215. * @hidden
  27216. */
  27217. export class DepthSortedParticle {
  27218. /**
  27219. * Index of the particle in the "indices" array
  27220. */
  27221. ind: number;
  27222. /**
  27223. * Length of the particle shape in the "indices" array
  27224. */
  27225. indicesLength: number;
  27226. /**
  27227. * Squared distance from the particle to the camera
  27228. */
  27229. sqDistance: number;
  27230. /**
  27231. * Material index when used with MultiMaterials
  27232. */
  27233. materialIndex: number;
  27234. /**
  27235. * Creates a new sorted particle
  27236. * @param materialIndex
  27237. */
  27238. constructor(ind: number, indLength: number, materialIndex: number);
  27239. }
  27240. }
  27241. declare module BABYLON {
  27242. /**
  27243. * @hidden
  27244. */
  27245. export class _MeshCollisionData {
  27246. _checkCollisions: boolean;
  27247. _collisionMask: number;
  27248. _collisionGroup: number;
  27249. _collider: Nullable<Collider>;
  27250. _oldPositionForCollisions: Vector3;
  27251. _diffPositionForCollisions: Vector3;
  27252. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27253. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27254. }
  27255. }
  27256. declare module BABYLON {
  27257. /** @hidden */
  27258. class _FacetDataStorage {
  27259. facetPositions: Vector3[];
  27260. facetNormals: Vector3[];
  27261. facetPartitioning: number[][];
  27262. facetNb: number;
  27263. partitioningSubdivisions: number;
  27264. partitioningBBoxRatio: number;
  27265. facetDataEnabled: boolean;
  27266. facetParameters: any;
  27267. bbSize: Vector3;
  27268. subDiv: {
  27269. max: number;
  27270. X: number;
  27271. Y: number;
  27272. Z: number;
  27273. };
  27274. facetDepthSort: boolean;
  27275. facetDepthSortEnabled: boolean;
  27276. depthSortedIndices: IndicesArray;
  27277. depthSortedFacets: {
  27278. ind: number;
  27279. sqDistance: number;
  27280. }[];
  27281. facetDepthSortFunction: (f1: {
  27282. ind: number;
  27283. sqDistance: number;
  27284. }, f2: {
  27285. ind: number;
  27286. sqDistance: number;
  27287. }) => number;
  27288. facetDepthSortFrom: Vector3;
  27289. facetDepthSortOrigin: Vector3;
  27290. invertedMatrix: Matrix;
  27291. }
  27292. /**
  27293. * @hidden
  27294. **/
  27295. class _InternalAbstractMeshDataInfo {
  27296. _hasVertexAlpha: boolean;
  27297. _useVertexColors: boolean;
  27298. _numBoneInfluencers: number;
  27299. _applyFog: boolean;
  27300. _receiveShadows: boolean;
  27301. _facetData: _FacetDataStorage;
  27302. _visibility: number;
  27303. _skeleton: Nullable<Skeleton>;
  27304. _layerMask: number;
  27305. _computeBonesUsingShaders: boolean;
  27306. _isActive: boolean;
  27307. _onlyForInstances: boolean;
  27308. _isActiveIntermediate: boolean;
  27309. _onlyForInstancesIntermediate: boolean;
  27310. _actAsRegularMesh: boolean;
  27311. }
  27312. /**
  27313. * Class used to store all common mesh properties
  27314. */
  27315. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27316. /** No occlusion */
  27317. static OCCLUSION_TYPE_NONE: number;
  27318. /** Occlusion set to optimisitic */
  27319. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27320. /** Occlusion set to strict */
  27321. static OCCLUSION_TYPE_STRICT: number;
  27322. /** Use an accurante occlusion algorithm */
  27323. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27324. /** Use a conservative occlusion algorithm */
  27325. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27326. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27327. * Test order :
  27328. * Is the bounding sphere outside the frustum ?
  27329. * If not, are the bounding box vertices outside the frustum ?
  27330. * It not, then the cullable object is in the frustum.
  27331. */
  27332. static readonly CULLINGSTRATEGY_STANDARD: number;
  27333. /** Culling strategy : Bounding Sphere Only.
  27334. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27335. * It's also less accurate than the standard because some not visible objects can still be selected.
  27336. * Test : is the bounding sphere outside the frustum ?
  27337. * If not, then the cullable object is in the frustum.
  27338. */
  27339. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27340. /** Culling strategy : Optimistic Inclusion.
  27341. * This in an inclusion test first, then the standard exclusion test.
  27342. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27343. * 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.
  27344. * Anyway, it's as accurate as the standard strategy.
  27345. * Test :
  27346. * Is the cullable object bounding sphere center in the frustum ?
  27347. * If not, apply the default culling strategy.
  27348. */
  27349. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27350. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27351. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27352. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27353. * 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.
  27354. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27355. * Test :
  27356. * Is the cullable object bounding sphere center in the frustum ?
  27357. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27358. */
  27359. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27360. /**
  27361. * No billboard
  27362. */
  27363. static readonly BILLBOARDMODE_NONE: number;
  27364. /** Billboard on X axis */
  27365. static readonly BILLBOARDMODE_X: number;
  27366. /** Billboard on Y axis */
  27367. static readonly BILLBOARDMODE_Y: number;
  27368. /** Billboard on Z axis */
  27369. static readonly BILLBOARDMODE_Z: number;
  27370. /** Billboard on all axes */
  27371. static readonly BILLBOARDMODE_ALL: number;
  27372. /** Billboard on using position instead of orientation */
  27373. static readonly BILLBOARDMODE_USE_POSITION: number;
  27374. /** @hidden */
  27375. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27376. /**
  27377. * The culling strategy to use to check whether the mesh must be rendered or not.
  27378. * This value can be changed at any time and will be used on the next render mesh selection.
  27379. * The possible values are :
  27380. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27381. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27382. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27383. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27384. * Please read each static variable documentation to get details about the culling process.
  27385. * */
  27386. cullingStrategy: number;
  27387. /**
  27388. * Gets the number of facets in the mesh
  27389. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27390. */
  27391. readonly facetNb: number;
  27392. /**
  27393. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27394. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27395. */
  27396. partitioningSubdivisions: number;
  27397. /**
  27398. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27399. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27400. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27401. */
  27402. partitioningBBoxRatio: number;
  27403. /**
  27404. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27405. * Works only for updatable meshes.
  27406. * Doesn't work with multi-materials
  27407. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27408. */
  27409. mustDepthSortFacets: boolean;
  27410. /**
  27411. * The location (Vector3) where the facet depth sort must be computed from.
  27412. * By default, the active camera position.
  27413. * Used only when facet depth sort is enabled
  27414. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27415. */
  27416. facetDepthSortFrom: Vector3;
  27417. /**
  27418. * gets a boolean indicating if facetData is enabled
  27419. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27420. */
  27421. readonly isFacetDataEnabled: boolean;
  27422. /** @hidden */
  27423. _updateNonUniformScalingState(value: boolean): boolean;
  27424. /**
  27425. * An event triggered when this mesh collides with another one
  27426. */
  27427. onCollideObservable: Observable<AbstractMesh>;
  27428. /** Set a function to call when this mesh collides with another one */
  27429. onCollide: () => void;
  27430. /**
  27431. * An event triggered when the collision's position changes
  27432. */
  27433. onCollisionPositionChangeObservable: Observable<Vector3>;
  27434. /** Set a function to call when the collision's position changes */
  27435. onCollisionPositionChange: () => void;
  27436. /**
  27437. * An event triggered when material is changed
  27438. */
  27439. onMaterialChangedObservable: Observable<AbstractMesh>;
  27440. /**
  27441. * Gets or sets the orientation for POV movement & rotation
  27442. */
  27443. definedFacingForward: boolean;
  27444. /** @hidden */
  27445. _occlusionQuery: Nullable<WebGLQuery>;
  27446. /** @hidden */
  27447. _renderingGroup: Nullable<RenderingGroup>;
  27448. /**
  27449. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27450. */
  27451. /**
  27452. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27453. */
  27454. visibility: number;
  27455. /** Gets or sets the alpha index used to sort transparent meshes
  27456. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27457. */
  27458. alphaIndex: number;
  27459. /**
  27460. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27461. */
  27462. isVisible: boolean;
  27463. /**
  27464. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27465. */
  27466. isPickable: boolean;
  27467. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27468. showSubMeshesBoundingBox: boolean;
  27469. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27470. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27471. */
  27472. isBlocker: boolean;
  27473. /**
  27474. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27475. */
  27476. enablePointerMoveEvents: boolean;
  27477. /**
  27478. * Specifies the rendering group id for this mesh (0 by default)
  27479. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27480. */
  27481. renderingGroupId: number;
  27482. private _material;
  27483. /** Gets or sets current material */
  27484. material: Nullable<Material>;
  27485. /**
  27486. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27487. * @see http://doc.babylonjs.com/babylon101/shadows
  27488. */
  27489. receiveShadows: boolean;
  27490. /** Defines color to use when rendering outline */
  27491. outlineColor: Color3;
  27492. /** Define width to use when rendering outline */
  27493. outlineWidth: number;
  27494. /** Defines color to use when rendering overlay */
  27495. overlayColor: Color3;
  27496. /** Defines alpha to use when rendering overlay */
  27497. overlayAlpha: number;
  27498. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27499. hasVertexAlpha: boolean;
  27500. /** 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) */
  27501. useVertexColors: boolean;
  27502. /**
  27503. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27504. */
  27505. computeBonesUsingShaders: boolean;
  27506. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27507. numBoneInfluencers: number;
  27508. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27509. applyFog: boolean;
  27510. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27511. useOctreeForRenderingSelection: boolean;
  27512. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27513. useOctreeForPicking: boolean;
  27514. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27515. useOctreeForCollisions: boolean;
  27516. /**
  27517. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27518. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27519. */
  27520. layerMask: number;
  27521. /**
  27522. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27523. */
  27524. alwaysSelectAsActiveMesh: boolean;
  27525. /**
  27526. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27527. */
  27528. doNotSyncBoundingInfo: boolean;
  27529. /**
  27530. * Gets or sets the current action manager
  27531. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27532. */
  27533. actionManager: Nullable<AbstractActionManager>;
  27534. private _meshCollisionData;
  27535. /**
  27536. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27537. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27538. */
  27539. ellipsoid: Vector3;
  27540. /**
  27541. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27542. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27543. */
  27544. ellipsoidOffset: Vector3;
  27545. /**
  27546. * Gets or sets a collision mask used to mask collisions (default is -1).
  27547. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27548. */
  27549. collisionMask: number;
  27550. /**
  27551. * Gets or sets the current collision group mask (-1 by default).
  27552. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27553. */
  27554. collisionGroup: number;
  27555. /**
  27556. * Defines edge width used when edgesRenderer is enabled
  27557. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27558. */
  27559. edgesWidth: number;
  27560. /**
  27561. * Defines edge color used when edgesRenderer is enabled
  27562. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27563. */
  27564. edgesColor: Color4;
  27565. /** @hidden */
  27566. _edgesRenderer: Nullable<IEdgesRenderer>;
  27567. /** @hidden */
  27568. _masterMesh: Nullable<AbstractMesh>;
  27569. /** @hidden */
  27570. _boundingInfo: Nullable<BoundingInfo>;
  27571. /** @hidden */
  27572. _renderId: number;
  27573. /**
  27574. * Gets or sets the list of subMeshes
  27575. * @see http://doc.babylonjs.com/how_to/multi_materials
  27576. */
  27577. subMeshes: SubMesh[];
  27578. /** @hidden */
  27579. _intersectionsInProgress: AbstractMesh[];
  27580. /** @hidden */
  27581. _unIndexed: boolean;
  27582. /** @hidden */
  27583. _lightSources: Light[];
  27584. /** Gets the list of lights affecting that mesh */
  27585. readonly lightSources: Light[];
  27586. /** @hidden */
  27587. readonly _positions: Nullable<Vector3[]>;
  27588. /** @hidden */
  27589. _waitingData: {
  27590. lods: Nullable<any>;
  27591. actions: Nullable<any>;
  27592. freezeWorldMatrix: Nullable<boolean>;
  27593. };
  27594. /** @hidden */
  27595. _bonesTransformMatrices: Nullable<Float32Array>;
  27596. /** @hidden */
  27597. _transformMatrixTexture: Nullable<RawTexture>;
  27598. /**
  27599. * Gets or sets a skeleton to apply skining transformations
  27600. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27601. */
  27602. skeleton: Nullable<Skeleton>;
  27603. /**
  27604. * An event triggered when the mesh is rebuilt.
  27605. */
  27606. onRebuildObservable: Observable<AbstractMesh>;
  27607. /**
  27608. * Creates a new AbstractMesh
  27609. * @param name defines the name of the mesh
  27610. * @param scene defines the hosting scene
  27611. */
  27612. constructor(name: string, scene?: Nullable<Scene>);
  27613. /**
  27614. * Returns the string "AbstractMesh"
  27615. * @returns "AbstractMesh"
  27616. */
  27617. getClassName(): string;
  27618. /**
  27619. * Gets a string representation of the current mesh
  27620. * @param fullDetails defines a boolean indicating if full details must be included
  27621. * @returns a string representation of the current mesh
  27622. */
  27623. toString(fullDetails?: boolean): string;
  27624. /**
  27625. * @hidden
  27626. */
  27627. protected _getEffectiveParent(): Nullable<Node>;
  27628. /** @hidden */
  27629. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27630. /** @hidden */
  27631. _rebuild(): void;
  27632. /** @hidden */
  27633. _resyncLightSources(): void;
  27634. /** @hidden */
  27635. _resyncLightSource(light: Light): void;
  27636. /** @hidden */
  27637. _unBindEffect(): void;
  27638. /** @hidden */
  27639. _removeLightSource(light: Light, dispose: boolean): void;
  27640. private _markSubMeshesAsDirty;
  27641. /** @hidden */
  27642. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27643. /** @hidden */
  27644. _markSubMeshesAsAttributesDirty(): void;
  27645. /** @hidden */
  27646. _markSubMeshesAsMiscDirty(): void;
  27647. /**
  27648. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27649. */
  27650. scaling: Vector3;
  27651. /**
  27652. * Returns true if the mesh is blocked. Implemented by child classes
  27653. */
  27654. readonly isBlocked: boolean;
  27655. /**
  27656. * Returns the mesh itself by default. Implemented by child classes
  27657. * @param camera defines the camera to use to pick the right LOD level
  27658. * @returns the currentAbstractMesh
  27659. */
  27660. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27661. /**
  27662. * Returns 0 by default. Implemented by child classes
  27663. * @returns an integer
  27664. */
  27665. getTotalVertices(): number;
  27666. /**
  27667. * Returns a positive integer : the total number of indices in this mesh geometry.
  27668. * @returns the numner of indices or zero if the mesh has no geometry.
  27669. */
  27670. getTotalIndices(): number;
  27671. /**
  27672. * Returns null by default. Implemented by child classes
  27673. * @returns null
  27674. */
  27675. getIndices(): Nullable<IndicesArray>;
  27676. /**
  27677. * Returns the array of the requested vertex data kind. Implemented by child classes
  27678. * @param kind defines the vertex data kind to use
  27679. * @returns null
  27680. */
  27681. getVerticesData(kind: string): Nullable<FloatArray>;
  27682. /**
  27683. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27684. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27685. * Note that a new underlying VertexBuffer object is created each call.
  27686. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27687. * @param kind defines vertex data kind:
  27688. * * VertexBuffer.PositionKind
  27689. * * VertexBuffer.UVKind
  27690. * * VertexBuffer.UV2Kind
  27691. * * VertexBuffer.UV3Kind
  27692. * * VertexBuffer.UV4Kind
  27693. * * VertexBuffer.UV5Kind
  27694. * * VertexBuffer.UV6Kind
  27695. * * VertexBuffer.ColorKind
  27696. * * VertexBuffer.MatricesIndicesKind
  27697. * * VertexBuffer.MatricesIndicesExtraKind
  27698. * * VertexBuffer.MatricesWeightsKind
  27699. * * VertexBuffer.MatricesWeightsExtraKind
  27700. * @param data defines the data source
  27701. * @param updatable defines if the data must be flagged as updatable (or static)
  27702. * @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
  27703. * @returns the current mesh
  27704. */
  27705. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27706. /**
  27707. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27708. * If the mesh has no geometry, it is simply returned as it is.
  27709. * @param kind defines vertex data kind:
  27710. * * VertexBuffer.PositionKind
  27711. * * VertexBuffer.UVKind
  27712. * * VertexBuffer.UV2Kind
  27713. * * VertexBuffer.UV3Kind
  27714. * * VertexBuffer.UV4Kind
  27715. * * VertexBuffer.UV5Kind
  27716. * * VertexBuffer.UV6Kind
  27717. * * VertexBuffer.ColorKind
  27718. * * VertexBuffer.MatricesIndicesKind
  27719. * * VertexBuffer.MatricesIndicesExtraKind
  27720. * * VertexBuffer.MatricesWeightsKind
  27721. * * VertexBuffer.MatricesWeightsExtraKind
  27722. * @param data defines the data source
  27723. * @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
  27724. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27725. * @returns the current mesh
  27726. */
  27727. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27728. /**
  27729. * Sets the mesh indices,
  27730. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27731. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27732. * @param totalVertices Defines the total number of vertices
  27733. * @returns the current mesh
  27734. */
  27735. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27736. /**
  27737. * Gets a boolean indicating if specific vertex data is present
  27738. * @param kind defines the vertex data kind to use
  27739. * @returns true is data kind is present
  27740. */
  27741. isVerticesDataPresent(kind: string): boolean;
  27742. /**
  27743. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27744. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27745. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27746. * @returns a BoundingInfo
  27747. */
  27748. getBoundingInfo(): BoundingInfo;
  27749. /**
  27750. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27751. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27752. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27753. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27754. * @returns the current mesh
  27755. */
  27756. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27757. /**
  27758. * Overwrite the current bounding info
  27759. * @param boundingInfo defines the new bounding info
  27760. * @returns the current mesh
  27761. */
  27762. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27763. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27764. readonly useBones: boolean;
  27765. /** @hidden */
  27766. _preActivate(): void;
  27767. /** @hidden */
  27768. _preActivateForIntermediateRendering(renderId: number): void;
  27769. /** @hidden */
  27770. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27771. /** @hidden */
  27772. _postActivate(): void;
  27773. /** @hidden */
  27774. _freeze(): void;
  27775. /** @hidden */
  27776. _unFreeze(): void;
  27777. /**
  27778. * Gets the current world matrix
  27779. * @returns a Matrix
  27780. */
  27781. getWorldMatrix(): Matrix;
  27782. /** @hidden */
  27783. _getWorldMatrixDeterminant(): number;
  27784. /**
  27785. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27786. */
  27787. readonly isAnInstance: boolean;
  27788. /**
  27789. * Gets a boolean indicating if this mesh has instances
  27790. */
  27791. readonly hasInstances: boolean;
  27792. /**
  27793. * Perform relative position change from the point of view of behind the front of the mesh.
  27794. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27795. * Supports definition of mesh facing forward or backward
  27796. * @param amountRight defines the distance on the right axis
  27797. * @param amountUp defines the distance on the up axis
  27798. * @param amountForward defines the distance on the forward axis
  27799. * @returns the current mesh
  27800. */
  27801. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27802. /**
  27803. * Calculate relative position change from the point of view of behind the front of the mesh.
  27804. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27805. * Supports definition of mesh facing forward or backward
  27806. * @param amountRight defines the distance on the right axis
  27807. * @param amountUp defines the distance on the up axis
  27808. * @param amountForward defines the distance on the forward axis
  27809. * @returns the new displacement vector
  27810. */
  27811. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27812. /**
  27813. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27814. * Supports definition of mesh facing forward or backward
  27815. * @param flipBack defines the flip
  27816. * @param twirlClockwise defines the twirl
  27817. * @param tiltRight defines the tilt
  27818. * @returns the current mesh
  27819. */
  27820. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27821. /**
  27822. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27823. * Supports definition of mesh facing forward or backward.
  27824. * @param flipBack defines the flip
  27825. * @param twirlClockwise defines the twirl
  27826. * @param tiltRight defines the tilt
  27827. * @returns the new rotation vector
  27828. */
  27829. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27830. /**
  27831. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27832. * This means the mesh underlying bounding box and sphere are recomputed.
  27833. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27834. * @returns the current mesh
  27835. */
  27836. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27837. /** @hidden */
  27838. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27839. /** @hidden */
  27840. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27841. /** @hidden */
  27842. _updateBoundingInfo(): AbstractMesh;
  27843. /** @hidden */
  27844. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27845. /** @hidden */
  27846. protected _afterComputeWorldMatrix(): void;
  27847. /** @hidden */
  27848. readonly _effectiveMesh: AbstractMesh;
  27849. /**
  27850. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27851. * A mesh is in the frustum if its bounding box intersects the frustum
  27852. * @param frustumPlanes defines the frustum to test
  27853. * @returns true if the mesh is in the frustum planes
  27854. */
  27855. isInFrustum(frustumPlanes: Plane[]): boolean;
  27856. /**
  27857. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27858. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27859. * @param frustumPlanes defines the frustum to test
  27860. * @returns true if the mesh is completely in the frustum planes
  27861. */
  27862. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27863. /**
  27864. * True if the mesh intersects another mesh or a SolidParticle object
  27865. * @param mesh defines a target mesh or SolidParticle to test
  27866. * @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)
  27867. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27868. * @returns true if there is an intersection
  27869. */
  27870. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27871. /**
  27872. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27873. * @param point defines the point to test
  27874. * @returns true if there is an intersection
  27875. */
  27876. intersectsPoint(point: Vector3): boolean;
  27877. /**
  27878. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27879. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27880. */
  27881. checkCollisions: boolean;
  27882. /**
  27883. * Gets Collider object used to compute collisions (not physics)
  27884. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27885. */
  27886. readonly collider: Nullable<Collider>;
  27887. /**
  27888. * Move the mesh using collision engine
  27889. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27890. * @param displacement defines the requested displacement vector
  27891. * @returns the current mesh
  27892. */
  27893. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27894. private _onCollisionPositionChange;
  27895. /** @hidden */
  27896. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27897. /** @hidden */
  27898. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27899. /** @hidden */
  27900. _checkCollision(collider: Collider): AbstractMesh;
  27901. /** @hidden */
  27902. _generatePointsArray(): boolean;
  27903. /**
  27904. * Checks if the passed Ray intersects with the mesh
  27905. * @param ray defines the ray to use
  27906. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27907. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27908. * @returns the picking info
  27909. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27910. */
  27911. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27912. /**
  27913. * Clones the current mesh
  27914. * @param name defines the mesh name
  27915. * @param newParent defines the new mesh parent
  27916. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27917. * @returns the new mesh
  27918. */
  27919. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27920. /**
  27921. * Disposes all the submeshes of the current meshnp
  27922. * @returns the current mesh
  27923. */
  27924. releaseSubMeshes(): AbstractMesh;
  27925. /**
  27926. * Releases resources associated with this abstract mesh.
  27927. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27928. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27929. */
  27930. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27931. /**
  27932. * Adds the passed mesh as a child to the current mesh
  27933. * @param mesh defines the child mesh
  27934. * @returns the current mesh
  27935. */
  27936. addChild(mesh: AbstractMesh): AbstractMesh;
  27937. /**
  27938. * Removes the passed mesh from the current mesh children list
  27939. * @param mesh defines the child mesh
  27940. * @returns the current mesh
  27941. */
  27942. removeChild(mesh: AbstractMesh): AbstractMesh;
  27943. /** @hidden */
  27944. private _initFacetData;
  27945. /**
  27946. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27947. * This method can be called within the render loop.
  27948. * 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
  27949. * @returns the current mesh
  27950. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27951. */
  27952. updateFacetData(): AbstractMesh;
  27953. /**
  27954. * Returns the facetLocalNormals array.
  27955. * The normals are expressed in the mesh local spac
  27956. * @returns an array of Vector3
  27957. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27958. */
  27959. getFacetLocalNormals(): Vector3[];
  27960. /**
  27961. * Returns the facetLocalPositions array.
  27962. * The facet positions are expressed in the mesh local space
  27963. * @returns an array of Vector3
  27964. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27965. */
  27966. getFacetLocalPositions(): Vector3[];
  27967. /**
  27968. * Returns the facetLocalPartioning array
  27969. * @returns an array of array of numbers
  27970. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27971. */
  27972. getFacetLocalPartitioning(): number[][];
  27973. /**
  27974. * Returns the i-th facet position in the world system.
  27975. * This method allocates a new Vector3 per call
  27976. * @param i defines the facet index
  27977. * @returns a new Vector3
  27978. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27979. */
  27980. getFacetPosition(i: number): Vector3;
  27981. /**
  27982. * Sets the reference Vector3 with the i-th facet position in the world system
  27983. * @param i defines the facet index
  27984. * @param ref defines the target vector
  27985. * @returns the current mesh
  27986. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27987. */
  27988. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27989. /**
  27990. * Returns the i-th facet normal in the world system.
  27991. * This method allocates a new Vector3 per call
  27992. * @param i defines the facet index
  27993. * @returns a new Vector3
  27994. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27995. */
  27996. getFacetNormal(i: number): Vector3;
  27997. /**
  27998. * Sets the reference Vector3 with the i-th facet normal in the world system
  27999. * @param i defines the facet index
  28000. * @param ref defines the target vector
  28001. * @returns the current mesh
  28002. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28003. */
  28004. getFacetNormalToRef(i: number, ref: Vector3): this;
  28005. /**
  28006. * 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)
  28007. * @param x defines x coordinate
  28008. * @param y defines y coordinate
  28009. * @param z defines z coordinate
  28010. * @returns the array of facet indexes
  28011. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28012. */
  28013. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28014. /**
  28015. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28016. * @param projected sets as the (x,y,z) world projection on the facet
  28017. * @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
  28018. * @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
  28019. * @param x defines x coordinate
  28020. * @param y defines y coordinate
  28021. * @param z defines z coordinate
  28022. * @returns the face index if found (or null instead)
  28023. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28024. */
  28025. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28026. /**
  28027. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28028. * @param projected sets as the (x,y,z) local projection on the facet
  28029. * @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
  28030. * @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
  28031. * @param x defines x coordinate
  28032. * @param y defines y coordinate
  28033. * @param z defines z coordinate
  28034. * @returns the face index if found (or null instead)
  28035. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28036. */
  28037. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28038. /**
  28039. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28040. * @returns the parameters
  28041. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28042. */
  28043. getFacetDataParameters(): any;
  28044. /**
  28045. * Disables the feature FacetData and frees the related memory
  28046. * @returns the current mesh
  28047. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28048. */
  28049. disableFacetData(): AbstractMesh;
  28050. /**
  28051. * Updates the AbstractMesh indices array
  28052. * @param indices defines the data source
  28053. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28054. * @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)
  28055. * @returns the current mesh
  28056. */
  28057. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28058. /**
  28059. * Creates new normals data for the mesh
  28060. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28061. * @returns the current mesh
  28062. */
  28063. createNormals(updatable: boolean): AbstractMesh;
  28064. /**
  28065. * Align the mesh with a normal
  28066. * @param normal defines the normal to use
  28067. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28068. * @returns the current mesh
  28069. */
  28070. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28071. /** @hidden */
  28072. _checkOcclusionQuery(): boolean;
  28073. /**
  28074. * Disables the mesh edge rendering mode
  28075. * @returns the currentAbstractMesh
  28076. */
  28077. disableEdgesRendering(): AbstractMesh;
  28078. /**
  28079. * Enables the edge rendering mode on the mesh.
  28080. * This mode makes the mesh edges visible
  28081. * @param epsilon defines the maximal distance between two angles to detect a face
  28082. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28083. * @returns the currentAbstractMesh
  28084. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28085. */
  28086. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28087. }
  28088. }
  28089. declare module BABYLON {
  28090. /**
  28091. * Interface used to define ActionEvent
  28092. */
  28093. export interface IActionEvent {
  28094. /** The mesh or sprite that triggered the action */
  28095. source: any;
  28096. /** The X mouse cursor position at the time of the event */
  28097. pointerX: number;
  28098. /** The Y mouse cursor position at the time of the event */
  28099. pointerY: number;
  28100. /** The mesh that is currently pointed at (can be null) */
  28101. meshUnderPointer: Nullable<AbstractMesh>;
  28102. /** the original (browser) event that triggered the ActionEvent */
  28103. sourceEvent?: any;
  28104. /** additional data for the event */
  28105. additionalData?: any;
  28106. }
  28107. /**
  28108. * ActionEvent is the event being sent when an action is triggered.
  28109. */
  28110. export class ActionEvent implements IActionEvent {
  28111. /** The mesh or sprite that triggered the action */
  28112. source: any;
  28113. /** The X mouse cursor position at the time of the event */
  28114. pointerX: number;
  28115. /** The Y mouse cursor position at the time of the event */
  28116. pointerY: number;
  28117. /** The mesh that is currently pointed at (can be null) */
  28118. meshUnderPointer: Nullable<AbstractMesh>;
  28119. /** the original (browser) event that triggered the ActionEvent */
  28120. sourceEvent?: any;
  28121. /** additional data for the event */
  28122. additionalData?: any;
  28123. /**
  28124. * Creates a new ActionEvent
  28125. * @param source The mesh or sprite that triggered the action
  28126. * @param pointerX The X mouse cursor position at the time of the event
  28127. * @param pointerY The Y mouse cursor position at the time of the event
  28128. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28129. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28130. * @param additionalData additional data for the event
  28131. */
  28132. constructor(
  28133. /** The mesh or sprite that triggered the action */
  28134. source: any,
  28135. /** The X mouse cursor position at the time of the event */
  28136. pointerX: number,
  28137. /** The Y mouse cursor position at the time of the event */
  28138. pointerY: number,
  28139. /** The mesh that is currently pointed at (can be null) */
  28140. meshUnderPointer: Nullable<AbstractMesh>,
  28141. /** the original (browser) event that triggered the ActionEvent */
  28142. sourceEvent?: any,
  28143. /** additional data for the event */
  28144. additionalData?: any);
  28145. /**
  28146. * Helper function to auto-create an ActionEvent from a source mesh.
  28147. * @param source The source mesh that triggered the event
  28148. * @param evt The original (browser) event
  28149. * @param additionalData additional data for the event
  28150. * @returns the new ActionEvent
  28151. */
  28152. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28153. /**
  28154. * Helper function to auto-create an ActionEvent from a source sprite
  28155. * @param source The source sprite that triggered the event
  28156. * @param scene Scene associated with the sprite
  28157. * @param evt The original (browser) event
  28158. * @param additionalData additional data for the event
  28159. * @returns the new ActionEvent
  28160. */
  28161. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28162. /**
  28163. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28164. * @param scene the scene where the event occurred
  28165. * @param evt The original (browser) event
  28166. * @returns the new ActionEvent
  28167. */
  28168. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28169. /**
  28170. * Helper function to auto-create an ActionEvent from a primitive
  28171. * @param prim defines the target primitive
  28172. * @param pointerPos defines the pointer position
  28173. * @param evt The original (browser) event
  28174. * @param additionalData additional data for the event
  28175. * @returns the new ActionEvent
  28176. */
  28177. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28178. }
  28179. }
  28180. declare module BABYLON {
  28181. /**
  28182. * Abstract class used to decouple action Manager from scene and meshes.
  28183. * Do not instantiate.
  28184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28185. */
  28186. export abstract class AbstractActionManager implements IDisposable {
  28187. /** Gets the list of active triggers */
  28188. static Triggers: {
  28189. [key: string]: number;
  28190. };
  28191. /** Gets the cursor to use when hovering items */
  28192. hoverCursor: string;
  28193. /** Gets the list of actions */
  28194. actions: IAction[];
  28195. /**
  28196. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28197. */
  28198. isRecursive: boolean;
  28199. /**
  28200. * Releases all associated resources
  28201. */
  28202. abstract dispose(): void;
  28203. /**
  28204. * Does this action manager has pointer triggers
  28205. */
  28206. abstract readonly hasPointerTriggers: boolean;
  28207. /**
  28208. * Does this action manager has pick triggers
  28209. */
  28210. abstract readonly hasPickTriggers: boolean;
  28211. /**
  28212. * Process a specific trigger
  28213. * @param trigger defines the trigger to process
  28214. * @param evt defines the event details to be processed
  28215. */
  28216. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28217. /**
  28218. * Does this action manager handles actions of any of the given triggers
  28219. * @param triggers defines the triggers to be tested
  28220. * @return a boolean indicating whether one (or more) of the triggers is handled
  28221. */
  28222. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28223. /**
  28224. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28225. * speed.
  28226. * @param triggerA defines the trigger to be tested
  28227. * @param triggerB defines the trigger to be tested
  28228. * @return a boolean indicating whether one (or more) of the triggers is handled
  28229. */
  28230. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28231. /**
  28232. * Does this action manager handles actions of a given trigger
  28233. * @param trigger defines the trigger to be tested
  28234. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28235. * @return whether the trigger is handled
  28236. */
  28237. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28238. /**
  28239. * Serialize this manager to a JSON object
  28240. * @param name defines the property name to store this manager
  28241. * @returns a JSON representation of this manager
  28242. */
  28243. abstract serialize(name: string): any;
  28244. /**
  28245. * Registers an action to this action manager
  28246. * @param action defines the action to be registered
  28247. * @return the action amended (prepared) after registration
  28248. */
  28249. abstract registerAction(action: IAction): Nullable<IAction>;
  28250. /**
  28251. * Unregisters an action to this action manager
  28252. * @param action defines the action to be unregistered
  28253. * @return a boolean indicating whether the action has been unregistered
  28254. */
  28255. abstract unregisterAction(action: IAction): Boolean;
  28256. /**
  28257. * Does exist one action manager with at least one trigger
  28258. **/
  28259. static readonly HasTriggers: boolean;
  28260. /**
  28261. * Does exist one action manager with at least one pick trigger
  28262. **/
  28263. static readonly HasPickTriggers: boolean;
  28264. /**
  28265. * Does exist one action manager that handles actions of a given trigger
  28266. * @param trigger defines the trigger to be tested
  28267. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28268. **/
  28269. static HasSpecificTrigger(trigger: number): boolean;
  28270. }
  28271. }
  28272. declare module BABYLON {
  28273. /**
  28274. * Defines how a node can be built from a string name.
  28275. */
  28276. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28277. /**
  28278. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28279. */
  28280. export class Node implements IBehaviorAware<Node> {
  28281. /** @hidden */
  28282. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28283. private static _NodeConstructors;
  28284. /**
  28285. * Add a new node constructor
  28286. * @param type defines the type name of the node to construct
  28287. * @param constructorFunc defines the constructor function
  28288. */
  28289. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28290. /**
  28291. * Returns a node constructor based on type name
  28292. * @param type defines the type name
  28293. * @param name defines the new node name
  28294. * @param scene defines the hosting scene
  28295. * @param options defines optional options to transmit to constructors
  28296. * @returns the new constructor or null
  28297. */
  28298. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28299. /**
  28300. * Gets or sets the name of the node
  28301. */
  28302. name: string;
  28303. /**
  28304. * Gets or sets the id of the node
  28305. */
  28306. id: string;
  28307. /**
  28308. * Gets or sets the unique id of the node
  28309. */
  28310. uniqueId: number;
  28311. /**
  28312. * Gets or sets a string used to store user defined state for the node
  28313. */
  28314. state: string;
  28315. /**
  28316. * Gets or sets an object used to store user defined information for the node
  28317. */
  28318. metadata: any;
  28319. /**
  28320. * For internal use only. Please do not use.
  28321. */
  28322. reservedDataStore: any;
  28323. /**
  28324. * List of inspectable custom properties (used by the Inspector)
  28325. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28326. */
  28327. inspectableCustomProperties: IInspectable[];
  28328. private _doNotSerialize;
  28329. /**
  28330. * Gets or sets a boolean used to define if the node must be serialized
  28331. */
  28332. doNotSerialize: boolean;
  28333. /** @hidden */
  28334. _isDisposed: boolean;
  28335. /**
  28336. * Gets a list of Animations associated with the node
  28337. */
  28338. animations: Animation[];
  28339. protected _ranges: {
  28340. [name: string]: Nullable<AnimationRange>;
  28341. };
  28342. /**
  28343. * Callback raised when the node is ready to be used
  28344. */
  28345. onReady: Nullable<(node: Node) => void>;
  28346. private _isEnabled;
  28347. private _isParentEnabled;
  28348. private _isReady;
  28349. /** @hidden */
  28350. _currentRenderId: number;
  28351. private _parentUpdateId;
  28352. /** @hidden */
  28353. _childUpdateId: number;
  28354. /** @hidden */
  28355. _waitingParentId: Nullable<string>;
  28356. /** @hidden */
  28357. _scene: Scene;
  28358. /** @hidden */
  28359. _cache: any;
  28360. private _parentNode;
  28361. private _children;
  28362. /** @hidden */
  28363. _worldMatrix: Matrix;
  28364. /** @hidden */
  28365. _worldMatrixDeterminant: number;
  28366. /** @hidden */
  28367. _worldMatrixDeterminantIsDirty: boolean;
  28368. /** @hidden */
  28369. private _sceneRootNodesIndex;
  28370. /**
  28371. * Gets a boolean indicating if the node has been disposed
  28372. * @returns true if the node was disposed
  28373. */
  28374. isDisposed(): boolean;
  28375. /**
  28376. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28377. * @see https://doc.babylonjs.com/how_to/parenting
  28378. */
  28379. parent: Nullable<Node>;
  28380. /** @hidden */
  28381. _addToSceneRootNodes(): void;
  28382. /** @hidden */
  28383. _removeFromSceneRootNodes(): void;
  28384. private _animationPropertiesOverride;
  28385. /**
  28386. * Gets or sets the animation properties override
  28387. */
  28388. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  28389. /**
  28390. * Gets a string idenfifying the name of the class
  28391. * @returns "Node" string
  28392. */
  28393. getClassName(): string;
  28394. /** @hidden */
  28395. readonly _isNode: boolean;
  28396. /**
  28397. * An event triggered when the mesh is disposed
  28398. */
  28399. onDisposeObservable: Observable<Node>;
  28400. private _onDisposeObserver;
  28401. /**
  28402. * Sets a callback that will be raised when the node will be disposed
  28403. */
  28404. onDispose: () => void;
  28405. /**
  28406. * Creates a new Node
  28407. * @param name the name and id to be given to this node
  28408. * @param scene the scene this node will be added to
  28409. */
  28410. constructor(name: string, scene?: Nullable<Scene>);
  28411. /**
  28412. * Gets the scene of the node
  28413. * @returns a scene
  28414. */
  28415. getScene(): Scene;
  28416. /**
  28417. * Gets the engine of the node
  28418. * @returns a Engine
  28419. */
  28420. getEngine(): Engine;
  28421. private _behaviors;
  28422. /**
  28423. * Attach a behavior to the node
  28424. * @see http://doc.babylonjs.com/features/behaviour
  28425. * @param behavior defines the behavior to attach
  28426. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28427. * @returns the current Node
  28428. */
  28429. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28430. /**
  28431. * Remove an attached behavior
  28432. * @see http://doc.babylonjs.com/features/behaviour
  28433. * @param behavior defines the behavior to attach
  28434. * @returns the current Node
  28435. */
  28436. removeBehavior(behavior: Behavior<Node>): Node;
  28437. /**
  28438. * Gets the list of attached behaviors
  28439. * @see http://doc.babylonjs.com/features/behaviour
  28440. */
  28441. readonly behaviors: Behavior<Node>[];
  28442. /**
  28443. * Gets an attached behavior by name
  28444. * @param name defines the name of the behavior to look for
  28445. * @see http://doc.babylonjs.com/features/behaviour
  28446. * @returns null if behavior was not found else the requested behavior
  28447. */
  28448. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28449. /**
  28450. * Returns the latest update of the World matrix
  28451. * @returns a Matrix
  28452. */
  28453. getWorldMatrix(): Matrix;
  28454. /** @hidden */
  28455. _getWorldMatrixDeterminant(): number;
  28456. /**
  28457. * Returns directly the latest state of the mesh World matrix.
  28458. * A Matrix is returned.
  28459. */
  28460. readonly worldMatrixFromCache: Matrix;
  28461. /** @hidden */
  28462. _initCache(): void;
  28463. /** @hidden */
  28464. updateCache(force?: boolean): void;
  28465. /** @hidden */
  28466. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28467. /** @hidden */
  28468. _updateCache(ignoreParentClass?: boolean): void;
  28469. /** @hidden */
  28470. _isSynchronized(): boolean;
  28471. /** @hidden */
  28472. _markSyncedWithParent(): void;
  28473. /** @hidden */
  28474. isSynchronizedWithParent(): boolean;
  28475. /** @hidden */
  28476. isSynchronized(): boolean;
  28477. /**
  28478. * Is this node ready to be used/rendered
  28479. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28480. * @return true if the node is ready
  28481. */
  28482. isReady(completeCheck?: boolean): boolean;
  28483. /**
  28484. * Is this node enabled?
  28485. * 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
  28486. * @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
  28487. * @return whether this node (and its parent) is enabled
  28488. */
  28489. isEnabled(checkAncestors?: boolean): boolean;
  28490. /** @hidden */
  28491. protected _syncParentEnabledState(): void;
  28492. /**
  28493. * Set the enabled state of this node
  28494. * @param value defines the new enabled state
  28495. */
  28496. setEnabled(value: boolean): void;
  28497. /**
  28498. * Is this node a descendant of the given node?
  28499. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28500. * @param ancestor defines the parent node to inspect
  28501. * @returns a boolean indicating if this node is a descendant of the given node
  28502. */
  28503. isDescendantOf(ancestor: Node): boolean;
  28504. /** @hidden */
  28505. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28506. /**
  28507. * Will return all nodes that have this node as ascendant
  28508. * @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
  28509. * @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
  28510. * @return all children nodes of all types
  28511. */
  28512. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28513. /**
  28514. * Get all child-meshes of this node
  28515. * @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)
  28516. * @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
  28517. * @returns an array of AbstractMesh
  28518. */
  28519. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28520. /**
  28521. * Get all direct children of this node
  28522. * @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
  28523. * @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)
  28524. * @returns an array of Node
  28525. */
  28526. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28527. /** @hidden */
  28528. _setReady(state: boolean): void;
  28529. /**
  28530. * Get an animation by name
  28531. * @param name defines the name of the animation to look for
  28532. * @returns null if not found else the requested animation
  28533. */
  28534. getAnimationByName(name: string): Nullable<Animation>;
  28535. /**
  28536. * Creates an animation range for this node
  28537. * @param name defines the name of the range
  28538. * @param from defines the starting key
  28539. * @param to defines the end key
  28540. */
  28541. createAnimationRange(name: string, from: number, to: number): void;
  28542. /**
  28543. * Delete a specific animation range
  28544. * @param name defines the name of the range to delete
  28545. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28546. */
  28547. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28548. /**
  28549. * Get an animation range by name
  28550. * @param name defines the name of the animation range to look for
  28551. * @returns null if not found else the requested animation range
  28552. */
  28553. getAnimationRange(name: string): Nullable<AnimationRange>;
  28554. /**
  28555. * Gets the list of all animation ranges defined on this node
  28556. * @returns an array
  28557. */
  28558. getAnimationRanges(): Nullable<AnimationRange>[];
  28559. /**
  28560. * Will start the animation sequence
  28561. * @param name defines the range frames for animation sequence
  28562. * @param loop defines if the animation should loop (false by default)
  28563. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28564. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28565. * @returns the object created for this animation. If range does not exist, it will return null
  28566. */
  28567. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28568. /**
  28569. * Serialize animation ranges into a JSON compatible object
  28570. * @returns serialization object
  28571. */
  28572. serializeAnimationRanges(): any;
  28573. /**
  28574. * Computes the world matrix of the node
  28575. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28576. * @returns the world matrix
  28577. */
  28578. computeWorldMatrix(force?: boolean): Matrix;
  28579. /**
  28580. * Releases resources associated with this node.
  28581. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28582. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28583. */
  28584. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28585. /**
  28586. * Parse animation range data from a serialization object and store them into a given node
  28587. * @param node defines where to store the animation ranges
  28588. * @param parsedNode defines the serialization object to read data from
  28589. * @param scene defines the hosting scene
  28590. */
  28591. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28592. /**
  28593. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28594. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28595. * @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
  28596. * @returns the new bounding vectors
  28597. */
  28598. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28599. min: Vector3;
  28600. max: Vector3;
  28601. };
  28602. }
  28603. }
  28604. declare module BABYLON {
  28605. /**
  28606. * @hidden
  28607. */
  28608. export class _IAnimationState {
  28609. key: number;
  28610. repeatCount: number;
  28611. workValue?: any;
  28612. loopMode?: number;
  28613. offsetValue?: any;
  28614. highLimitValue?: any;
  28615. }
  28616. /**
  28617. * Class used to store any kind of animation
  28618. */
  28619. export class Animation {
  28620. /**Name of the animation */
  28621. name: string;
  28622. /**Property to animate */
  28623. targetProperty: string;
  28624. /**The frames per second of the animation */
  28625. framePerSecond: number;
  28626. /**The data type of the animation */
  28627. dataType: number;
  28628. /**The loop mode of the animation */
  28629. loopMode?: number | undefined;
  28630. /**Specifies if blending should be enabled */
  28631. enableBlending?: boolean | undefined;
  28632. /**
  28633. * Use matrix interpolation instead of using direct key value when animating matrices
  28634. */
  28635. static AllowMatricesInterpolation: boolean;
  28636. /**
  28637. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28638. */
  28639. static AllowMatrixDecomposeForInterpolation: boolean;
  28640. /**
  28641. * Stores the key frames of the animation
  28642. */
  28643. private _keys;
  28644. /**
  28645. * Stores the easing function of the animation
  28646. */
  28647. private _easingFunction;
  28648. /**
  28649. * @hidden Internal use only
  28650. */
  28651. _runtimeAnimations: RuntimeAnimation[];
  28652. /**
  28653. * The set of event that will be linked to this animation
  28654. */
  28655. private _events;
  28656. /**
  28657. * Stores an array of target property paths
  28658. */
  28659. targetPropertyPath: string[];
  28660. /**
  28661. * Stores the blending speed of the animation
  28662. */
  28663. blendingSpeed: number;
  28664. /**
  28665. * Stores the animation ranges for the animation
  28666. */
  28667. private _ranges;
  28668. /**
  28669. * @hidden Internal use
  28670. */
  28671. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28672. /**
  28673. * Sets up an animation
  28674. * @param property The property to animate
  28675. * @param animationType The animation type to apply
  28676. * @param framePerSecond The frames per second of the animation
  28677. * @param easingFunction The easing function used in the animation
  28678. * @returns The created animation
  28679. */
  28680. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28681. /**
  28682. * Create and start an animation on a node
  28683. * @param name defines the name of the global animation that will be run on all nodes
  28684. * @param node defines the root node where the animation will take place
  28685. * @param targetProperty defines property to animate
  28686. * @param framePerSecond defines the number of frame per second yo use
  28687. * @param totalFrame defines the number of frames in total
  28688. * @param from defines the initial value
  28689. * @param to defines the final value
  28690. * @param loopMode defines which loop mode you want to use (off by default)
  28691. * @param easingFunction defines the easing function to use (linear by default)
  28692. * @param onAnimationEnd defines the callback to call when animation end
  28693. * @returns the animatable created for this animation
  28694. */
  28695. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28696. /**
  28697. * Create and start an animation on a node and its descendants
  28698. * @param name defines the name of the global animation that will be run on all nodes
  28699. * @param node defines the root node where the animation will take place
  28700. * @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
  28701. * @param targetProperty defines property to animate
  28702. * @param framePerSecond defines the number of frame per second to use
  28703. * @param totalFrame defines the number of frames in total
  28704. * @param from defines the initial value
  28705. * @param to defines the final value
  28706. * @param loopMode defines which loop mode you want to use (off by default)
  28707. * @param easingFunction defines the easing function to use (linear by default)
  28708. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28709. * @returns the list of animatables created for all nodes
  28710. * @example https://www.babylonjs-playground.com/#MH0VLI
  28711. */
  28712. 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[]>;
  28713. /**
  28714. * Creates a new animation, merges it with the existing animations and starts it
  28715. * @param name Name of the animation
  28716. * @param node Node which contains the scene that begins the animations
  28717. * @param targetProperty Specifies which property to animate
  28718. * @param framePerSecond The frames per second of the animation
  28719. * @param totalFrame The total number of frames
  28720. * @param from The frame at the beginning of the animation
  28721. * @param to The frame at the end of the animation
  28722. * @param loopMode Specifies the loop mode of the animation
  28723. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28724. * @param onAnimationEnd Callback to run once the animation is complete
  28725. * @returns Nullable animation
  28726. */
  28727. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28728. /**
  28729. * Transition property of an host to the target Value
  28730. * @param property The property to transition
  28731. * @param targetValue The target Value of the property
  28732. * @param host The object where the property to animate belongs
  28733. * @param scene Scene used to run the animation
  28734. * @param frameRate Framerate (in frame/s) to use
  28735. * @param transition The transition type we want to use
  28736. * @param duration The duration of the animation, in milliseconds
  28737. * @param onAnimationEnd Callback trigger at the end of the animation
  28738. * @returns Nullable animation
  28739. */
  28740. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28741. /**
  28742. * Return the array of runtime animations currently using this animation
  28743. */
  28744. readonly runtimeAnimations: RuntimeAnimation[];
  28745. /**
  28746. * Specifies if any of the runtime animations are currently running
  28747. */
  28748. readonly hasRunningRuntimeAnimations: boolean;
  28749. /**
  28750. * Initializes the animation
  28751. * @param name Name of the animation
  28752. * @param targetProperty Property to animate
  28753. * @param framePerSecond The frames per second of the animation
  28754. * @param dataType The data type of the animation
  28755. * @param loopMode The loop mode of the animation
  28756. * @param enableBlending Specifies if blending should be enabled
  28757. */
  28758. constructor(
  28759. /**Name of the animation */
  28760. name: string,
  28761. /**Property to animate */
  28762. targetProperty: string,
  28763. /**The frames per second of the animation */
  28764. framePerSecond: number,
  28765. /**The data type of the animation */
  28766. dataType: number,
  28767. /**The loop mode of the animation */
  28768. loopMode?: number | undefined,
  28769. /**Specifies if blending should be enabled */
  28770. enableBlending?: boolean | undefined);
  28771. /**
  28772. * Converts the animation to a string
  28773. * @param fullDetails support for multiple levels of logging within scene loading
  28774. * @returns String form of the animation
  28775. */
  28776. toString(fullDetails?: boolean): string;
  28777. /**
  28778. * Add an event to this animation
  28779. * @param event Event to add
  28780. */
  28781. addEvent(event: AnimationEvent): void;
  28782. /**
  28783. * Remove all events found at the given frame
  28784. * @param frame The frame to remove events from
  28785. */
  28786. removeEvents(frame: number): void;
  28787. /**
  28788. * Retrieves all the events from the animation
  28789. * @returns Events from the animation
  28790. */
  28791. getEvents(): AnimationEvent[];
  28792. /**
  28793. * Creates an animation range
  28794. * @param name Name of the animation range
  28795. * @param from Starting frame of the animation range
  28796. * @param to Ending frame of the animation
  28797. */
  28798. createRange(name: string, from: number, to: number): void;
  28799. /**
  28800. * Deletes an animation range by name
  28801. * @param name Name of the animation range to delete
  28802. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28803. */
  28804. deleteRange(name: string, deleteFrames?: boolean): void;
  28805. /**
  28806. * Gets the animation range by name, or null if not defined
  28807. * @param name Name of the animation range
  28808. * @returns Nullable animation range
  28809. */
  28810. getRange(name: string): Nullable<AnimationRange>;
  28811. /**
  28812. * Gets the key frames from the animation
  28813. * @returns The key frames of the animation
  28814. */
  28815. getKeys(): Array<IAnimationKey>;
  28816. /**
  28817. * Gets the highest frame rate of the animation
  28818. * @returns Highest frame rate of the animation
  28819. */
  28820. getHighestFrame(): number;
  28821. /**
  28822. * Gets the easing function of the animation
  28823. * @returns Easing function of the animation
  28824. */
  28825. getEasingFunction(): IEasingFunction;
  28826. /**
  28827. * Sets the easing function of the animation
  28828. * @param easingFunction A custom mathematical formula for animation
  28829. */
  28830. setEasingFunction(easingFunction: EasingFunction): void;
  28831. /**
  28832. * Interpolates a scalar linearly
  28833. * @param startValue Start value of the animation curve
  28834. * @param endValue End value of the animation curve
  28835. * @param gradient Scalar amount to interpolate
  28836. * @returns Interpolated scalar value
  28837. */
  28838. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28839. /**
  28840. * Interpolates a scalar cubically
  28841. * @param startValue Start value of the animation curve
  28842. * @param outTangent End tangent of the animation
  28843. * @param endValue End value of the animation curve
  28844. * @param inTangent Start tangent of the animation curve
  28845. * @param gradient Scalar amount to interpolate
  28846. * @returns Interpolated scalar value
  28847. */
  28848. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28849. /**
  28850. * Interpolates a quaternion using a spherical linear interpolation
  28851. * @param startValue Start value of the animation curve
  28852. * @param endValue End value of the animation curve
  28853. * @param gradient Scalar amount to interpolate
  28854. * @returns Interpolated quaternion value
  28855. */
  28856. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28857. /**
  28858. * Interpolates a quaternion cubically
  28859. * @param startValue Start value of the animation curve
  28860. * @param outTangent End tangent of the animation curve
  28861. * @param endValue End value of the animation curve
  28862. * @param inTangent Start tangent of the animation curve
  28863. * @param gradient Scalar amount to interpolate
  28864. * @returns Interpolated quaternion value
  28865. */
  28866. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28867. /**
  28868. * Interpolates a Vector3 linearl
  28869. * @param startValue Start value of the animation curve
  28870. * @param endValue End value of the animation curve
  28871. * @param gradient Scalar amount to interpolate
  28872. * @returns Interpolated scalar value
  28873. */
  28874. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28875. /**
  28876. * Interpolates a Vector3 cubically
  28877. * @param startValue Start value of the animation curve
  28878. * @param outTangent End tangent of the animation
  28879. * @param endValue End value of the animation curve
  28880. * @param inTangent Start tangent of the animation curve
  28881. * @param gradient Scalar amount to interpolate
  28882. * @returns InterpolatedVector3 value
  28883. */
  28884. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28885. /**
  28886. * Interpolates a Vector2 linearly
  28887. * @param startValue Start value of the animation curve
  28888. * @param endValue End value of the animation curve
  28889. * @param gradient Scalar amount to interpolate
  28890. * @returns Interpolated Vector2 value
  28891. */
  28892. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28893. /**
  28894. * Interpolates a Vector2 cubically
  28895. * @param startValue Start value of the animation curve
  28896. * @param outTangent End tangent of the animation
  28897. * @param endValue End value of the animation curve
  28898. * @param inTangent Start tangent of the animation curve
  28899. * @param gradient Scalar amount to interpolate
  28900. * @returns Interpolated Vector2 value
  28901. */
  28902. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28903. /**
  28904. * Interpolates a size linearly
  28905. * @param startValue Start value of the animation curve
  28906. * @param endValue End value of the animation curve
  28907. * @param gradient Scalar amount to interpolate
  28908. * @returns Interpolated Size value
  28909. */
  28910. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28911. /**
  28912. * Interpolates a Color3 linearly
  28913. * @param startValue Start value of the animation curve
  28914. * @param endValue End value of the animation curve
  28915. * @param gradient Scalar amount to interpolate
  28916. * @returns Interpolated Color3 value
  28917. */
  28918. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28919. /**
  28920. * Interpolates a Color4 linearly
  28921. * @param startValue Start value of the animation curve
  28922. * @param endValue End value of the animation curve
  28923. * @param gradient Scalar amount to interpolate
  28924. * @returns Interpolated Color3 value
  28925. */
  28926. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  28927. /**
  28928. * @hidden Internal use only
  28929. */
  28930. _getKeyValue(value: any): any;
  28931. /**
  28932. * @hidden Internal use only
  28933. */
  28934. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28935. /**
  28936. * Defines the function to use to interpolate matrices
  28937. * @param startValue defines the start matrix
  28938. * @param endValue defines the end matrix
  28939. * @param gradient defines the gradient between both matrices
  28940. * @param result defines an optional target matrix where to store the interpolation
  28941. * @returns the interpolated matrix
  28942. */
  28943. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28944. /**
  28945. * Makes a copy of the animation
  28946. * @returns Cloned animation
  28947. */
  28948. clone(): Animation;
  28949. /**
  28950. * Sets the key frames of the animation
  28951. * @param values The animation key frames to set
  28952. */
  28953. setKeys(values: Array<IAnimationKey>): void;
  28954. /**
  28955. * Serializes the animation to an object
  28956. * @returns Serialized object
  28957. */
  28958. serialize(): any;
  28959. /**
  28960. * Float animation type
  28961. */
  28962. static readonly ANIMATIONTYPE_FLOAT: number;
  28963. /**
  28964. * Vector3 animation type
  28965. */
  28966. static readonly ANIMATIONTYPE_VECTOR3: number;
  28967. /**
  28968. * Quaternion animation type
  28969. */
  28970. static readonly ANIMATIONTYPE_QUATERNION: number;
  28971. /**
  28972. * Matrix animation type
  28973. */
  28974. static readonly ANIMATIONTYPE_MATRIX: number;
  28975. /**
  28976. * Color3 animation type
  28977. */
  28978. static readonly ANIMATIONTYPE_COLOR3: number;
  28979. /**
  28980. * Color3 animation type
  28981. */
  28982. static readonly ANIMATIONTYPE_COLOR4: number;
  28983. /**
  28984. * Vector2 animation type
  28985. */
  28986. static readonly ANIMATIONTYPE_VECTOR2: number;
  28987. /**
  28988. * Size animation type
  28989. */
  28990. static readonly ANIMATIONTYPE_SIZE: number;
  28991. /**
  28992. * Relative Loop Mode
  28993. */
  28994. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28995. /**
  28996. * Cycle Loop Mode
  28997. */
  28998. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28999. /**
  29000. * Constant Loop Mode
  29001. */
  29002. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29003. /** @hidden */
  29004. static _UniversalLerp(left: any, right: any, amount: number): any;
  29005. /**
  29006. * Parses an animation object and creates an animation
  29007. * @param parsedAnimation Parsed animation object
  29008. * @returns Animation object
  29009. */
  29010. static Parse(parsedAnimation: any): Animation;
  29011. /**
  29012. * Appends the serialized animations from the source animations
  29013. * @param source Source containing the animations
  29014. * @param destination Target to store the animations
  29015. */
  29016. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29017. }
  29018. }
  29019. declare module BABYLON {
  29020. /**
  29021. * Interface containing an array of animations
  29022. */
  29023. export interface IAnimatable {
  29024. /**
  29025. * Array of animations
  29026. */
  29027. animations: Nullable<Array<Animation>>;
  29028. }
  29029. }
  29030. declare module BABYLON {
  29031. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29032. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29033. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29034. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29035. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29036. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29037. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29038. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29039. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29040. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29041. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29042. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29043. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29044. /**
  29045. * Decorator used to define property that can be serialized as reference to a camera
  29046. * @param sourceName defines the name of the property to decorate
  29047. */
  29048. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29049. /**
  29050. * Class used to help serialization objects
  29051. */
  29052. export class SerializationHelper {
  29053. /** @hidden */
  29054. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29055. /** @hidden */
  29056. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29057. /** @hidden */
  29058. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29059. /** @hidden */
  29060. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29061. /**
  29062. * Appends the serialized animations from the source animations
  29063. * @param source Source containing the animations
  29064. * @param destination Target to store the animations
  29065. */
  29066. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29067. /**
  29068. * Static function used to serialized a specific entity
  29069. * @param entity defines the entity to serialize
  29070. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29071. * @returns a JSON compatible object representing the serialization of the entity
  29072. */
  29073. static Serialize<T>(entity: T, serializationObject?: any): any;
  29074. /**
  29075. * Creates a new entity from a serialization data object
  29076. * @param creationFunction defines a function used to instanciated the new entity
  29077. * @param source defines the source serialization data
  29078. * @param scene defines the hosting scene
  29079. * @param rootUrl defines the root url for resources
  29080. * @returns a new entity
  29081. */
  29082. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29083. /**
  29084. * Clones an object
  29085. * @param creationFunction defines the function used to instanciate the new object
  29086. * @param source defines the source object
  29087. * @returns the cloned object
  29088. */
  29089. static Clone<T>(creationFunction: () => T, source: T): T;
  29090. /**
  29091. * Instanciates a new object based on a source one (some data will be shared between both object)
  29092. * @param creationFunction defines the function used to instanciate the new object
  29093. * @param source defines the source object
  29094. * @returns the new object
  29095. */
  29096. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29097. }
  29098. }
  29099. declare module BABYLON {
  29100. /**
  29101. * Class used to manipulate GUIDs
  29102. */
  29103. export class GUID {
  29104. /**
  29105. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29106. * Be aware Math.random() could cause collisions, but:
  29107. * "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"
  29108. * @returns a pseudo random id
  29109. */
  29110. static RandomId(): string;
  29111. }
  29112. }
  29113. declare module BABYLON {
  29114. /**
  29115. * Base class of all the textures in babylon.
  29116. * It groups all the common properties the materials, post process, lights... might need
  29117. * in order to make a correct use of the texture.
  29118. */
  29119. export class BaseTexture implements IAnimatable {
  29120. /**
  29121. * Default anisotropic filtering level for the application.
  29122. * It is set to 4 as a good tradeoff between perf and quality.
  29123. */
  29124. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29125. /**
  29126. * Gets or sets the unique id of the texture
  29127. */
  29128. uniqueId: number;
  29129. /**
  29130. * Define the name of the texture.
  29131. */
  29132. name: string;
  29133. /**
  29134. * Gets or sets an object used to store user defined information.
  29135. */
  29136. metadata: any;
  29137. /**
  29138. * For internal use only. Please do not use.
  29139. */
  29140. reservedDataStore: any;
  29141. private _hasAlpha;
  29142. /**
  29143. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29144. */
  29145. hasAlpha: boolean;
  29146. /**
  29147. * Defines if the alpha value should be determined via the rgb values.
  29148. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29149. */
  29150. getAlphaFromRGB: boolean;
  29151. /**
  29152. * Intensity or strength of the texture.
  29153. * It is commonly used by materials to fine tune the intensity of the texture
  29154. */
  29155. level: number;
  29156. /**
  29157. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29158. * This is part of the texture as textures usually maps to one uv set.
  29159. */
  29160. coordinatesIndex: number;
  29161. private _coordinatesMode;
  29162. /**
  29163. * How a texture is mapped.
  29164. *
  29165. * | Value | Type | Description |
  29166. * | ----- | ----------------------------------- | ----------- |
  29167. * | 0 | EXPLICIT_MODE | |
  29168. * | 1 | SPHERICAL_MODE | |
  29169. * | 2 | PLANAR_MODE | |
  29170. * | 3 | CUBIC_MODE | |
  29171. * | 4 | PROJECTION_MODE | |
  29172. * | 5 | SKYBOX_MODE | |
  29173. * | 6 | INVCUBIC_MODE | |
  29174. * | 7 | EQUIRECTANGULAR_MODE | |
  29175. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29176. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29177. */
  29178. coordinatesMode: number;
  29179. /**
  29180. * | Value | Type | Description |
  29181. * | ----- | ------------------ | ----------- |
  29182. * | 0 | CLAMP_ADDRESSMODE | |
  29183. * | 1 | WRAP_ADDRESSMODE | |
  29184. * | 2 | MIRROR_ADDRESSMODE | |
  29185. */
  29186. wrapU: number;
  29187. /**
  29188. * | Value | Type | Description |
  29189. * | ----- | ------------------ | ----------- |
  29190. * | 0 | CLAMP_ADDRESSMODE | |
  29191. * | 1 | WRAP_ADDRESSMODE | |
  29192. * | 2 | MIRROR_ADDRESSMODE | |
  29193. */
  29194. wrapV: number;
  29195. /**
  29196. * | Value | Type | Description |
  29197. * | ----- | ------------------ | ----------- |
  29198. * | 0 | CLAMP_ADDRESSMODE | |
  29199. * | 1 | WRAP_ADDRESSMODE | |
  29200. * | 2 | MIRROR_ADDRESSMODE | |
  29201. */
  29202. wrapR: number;
  29203. /**
  29204. * With compliant hardware and browser (supporting anisotropic filtering)
  29205. * this defines the level of anisotropic filtering in the texture.
  29206. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29207. */
  29208. anisotropicFilteringLevel: number;
  29209. /**
  29210. * Define if the texture is a cube texture or if false a 2d texture.
  29211. */
  29212. isCube: boolean;
  29213. /**
  29214. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29215. */
  29216. is3D: boolean;
  29217. /**
  29218. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29219. */
  29220. is2DArray: boolean;
  29221. /**
  29222. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29223. * HDR texture are usually stored in linear space.
  29224. * This only impacts the PBR and Background materials
  29225. */
  29226. gammaSpace: boolean;
  29227. /**
  29228. * Gets or sets whether or not the texture contains RGBD data.
  29229. */
  29230. isRGBD: boolean;
  29231. /**
  29232. * Is Z inverted in the texture (useful in a cube texture).
  29233. */
  29234. invertZ: boolean;
  29235. /**
  29236. * Are mip maps generated for this texture or not.
  29237. */
  29238. readonly noMipmap: boolean;
  29239. /**
  29240. * @hidden
  29241. */
  29242. lodLevelInAlpha: boolean;
  29243. /**
  29244. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29245. */
  29246. lodGenerationOffset: number;
  29247. /**
  29248. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29249. */
  29250. lodGenerationScale: number;
  29251. /**
  29252. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29253. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29254. * average roughness values.
  29255. */
  29256. linearSpecularLOD: boolean;
  29257. /**
  29258. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29259. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29260. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29261. */
  29262. irradianceTexture: Nullable<BaseTexture>;
  29263. /**
  29264. * Define if the texture is a render target.
  29265. */
  29266. isRenderTarget: boolean;
  29267. /**
  29268. * Define the unique id of the texture in the scene.
  29269. */
  29270. readonly uid: string;
  29271. /**
  29272. * Return a string representation of the texture.
  29273. * @returns the texture as a string
  29274. */
  29275. toString(): string;
  29276. /**
  29277. * Get the class name of the texture.
  29278. * @returns "BaseTexture"
  29279. */
  29280. getClassName(): string;
  29281. /**
  29282. * Define the list of animation attached to the texture.
  29283. */
  29284. animations: Animation[];
  29285. /**
  29286. * An event triggered when the texture is disposed.
  29287. */
  29288. onDisposeObservable: Observable<BaseTexture>;
  29289. private _onDisposeObserver;
  29290. /**
  29291. * Callback triggered when the texture has been disposed.
  29292. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29293. */
  29294. onDispose: () => void;
  29295. /**
  29296. * Define the current state of the loading sequence when in delayed load mode.
  29297. */
  29298. delayLoadState: number;
  29299. private _scene;
  29300. /** @hidden */
  29301. _texture: Nullable<InternalTexture>;
  29302. private _uid;
  29303. /**
  29304. * Define if the texture is preventinga material to render or not.
  29305. * If not and the texture is not ready, the engine will use a default black texture instead.
  29306. */
  29307. readonly isBlocking: boolean;
  29308. /**
  29309. * Instantiates a new BaseTexture.
  29310. * Base class of all the textures in babylon.
  29311. * It groups all the common properties the materials, post process, lights... might need
  29312. * in order to make a correct use of the texture.
  29313. * @param scene Define the scene the texture blongs to
  29314. */
  29315. constructor(scene: Nullable<Scene>);
  29316. /**
  29317. * Get the scene the texture belongs to.
  29318. * @returns the scene or null if undefined
  29319. */
  29320. getScene(): Nullable<Scene>;
  29321. /**
  29322. * Get the texture transform matrix used to offset tile the texture for istance.
  29323. * @returns the transformation matrix
  29324. */
  29325. getTextureMatrix(): Matrix;
  29326. /**
  29327. * Get the texture reflection matrix used to rotate/transform the reflection.
  29328. * @returns the reflection matrix
  29329. */
  29330. getReflectionTextureMatrix(): Matrix;
  29331. /**
  29332. * Get the underlying lower level texture from Babylon.
  29333. * @returns the insternal texture
  29334. */
  29335. getInternalTexture(): Nullable<InternalTexture>;
  29336. /**
  29337. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29338. * @returns true if ready or not blocking
  29339. */
  29340. isReadyOrNotBlocking(): boolean;
  29341. /**
  29342. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29343. * @returns true if fully ready
  29344. */
  29345. isReady(): boolean;
  29346. private _cachedSize;
  29347. /**
  29348. * Get the size of the texture.
  29349. * @returns the texture size.
  29350. */
  29351. getSize(): ISize;
  29352. /**
  29353. * Get the base size of the texture.
  29354. * It can be different from the size if the texture has been resized for POT for instance
  29355. * @returns the base size
  29356. */
  29357. getBaseSize(): ISize;
  29358. /**
  29359. * Update the sampling mode of the texture.
  29360. * Default is Trilinear mode.
  29361. *
  29362. * | Value | Type | Description |
  29363. * | ----- | ------------------ | ----------- |
  29364. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29365. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29366. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29367. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29368. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29369. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29370. * | 7 | NEAREST_LINEAR | |
  29371. * | 8 | NEAREST_NEAREST | |
  29372. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29373. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29374. * | 11 | LINEAR_LINEAR | |
  29375. * | 12 | LINEAR_NEAREST | |
  29376. *
  29377. * > _mag_: magnification filter (close to the viewer)
  29378. * > _min_: minification filter (far from the viewer)
  29379. * > _mip_: filter used between mip map levels
  29380. *@param samplingMode Define the new sampling mode of the texture
  29381. */
  29382. updateSamplingMode(samplingMode: number): void;
  29383. /**
  29384. * Scales the texture if is `canRescale()`
  29385. * @param ratio the resize factor we want to use to rescale
  29386. */
  29387. scale(ratio: number): void;
  29388. /**
  29389. * Get if the texture can rescale.
  29390. */
  29391. readonly canRescale: boolean;
  29392. /** @hidden */
  29393. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29394. /** @hidden */
  29395. _rebuild(): void;
  29396. /**
  29397. * Triggers the load sequence in delayed load mode.
  29398. */
  29399. delayLoad(): void;
  29400. /**
  29401. * Clones the texture.
  29402. * @returns the cloned texture
  29403. */
  29404. clone(): Nullable<BaseTexture>;
  29405. /**
  29406. * Get the texture underlying type (INT, FLOAT...)
  29407. */
  29408. readonly textureType: number;
  29409. /**
  29410. * Get the texture underlying format (RGB, RGBA...)
  29411. */
  29412. readonly textureFormat: number;
  29413. /**
  29414. * Indicates that textures need to be re-calculated for all materials
  29415. */
  29416. protected _markAllSubMeshesAsTexturesDirty(): void;
  29417. /**
  29418. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29419. * This will returns an RGBA array buffer containing either in values (0-255) or
  29420. * float values (0-1) depending of the underlying buffer type.
  29421. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29422. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29423. * @param buffer defines a user defined buffer to fill with data (can be null)
  29424. * @returns The Array buffer containing the pixels data.
  29425. */
  29426. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29427. /**
  29428. * Release and destroy the underlying lower level texture aka internalTexture.
  29429. */
  29430. releaseInternalTexture(): void;
  29431. /** @hidden */
  29432. readonly _lodTextureHigh: Nullable<BaseTexture>;
  29433. /** @hidden */
  29434. readonly _lodTextureMid: Nullable<BaseTexture>;
  29435. /** @hidden */
  29436. readonly _lodTextureLow: Nullable<BaseTexture>;
  29437. /**
  29438. * Dispose the texture and release its associated resources.
  29439. */
  29440. dispose(): void;
  29441. /**
  29442. * Serialize the texture into a JSON representation that can be parsed later on.
  29443. * @returns the JSON representation of the texture
  29444. */
  29445. serialize(): any;
  29446. /**
  29447. * Helper function to be called back once a list of texture contains only ready textures.
  29448. * @param textures Define the list of textures to wait for
  29449. * @param callback Define the callback triggered once the entire list will be ready
  29450. */
  29451. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29452. }
  29453. }
  29454. declare module BABYLON {
  29455. /**
  29456. * Options to be used when creating an effect.
  29457. */
  29458. export interface IEffectCreationOptions {
  29459. /**
  29460. * Atrributes that will be used in the shader.
  29461. */
  29462. attributes: string[];
  29463. /**
  29464. * Uniform varible names that will be set in the shader.
  29465. */
  29466. uniformsNames: string[];
  29467. /**
  29468. * Uniform buffer variable names that will be set in the shader.
  29469. */
  29470. uniformBuffersNames: string[];
  29471. /**
  29472. * Sampler texture variable names that will be set in the shader.
  29473. */
  29474. samplers: string[];
  29475. /**
  29476. * Define statements that will be set in the shader.
  29477. */
  29478. defines: any;
  29479. /**
  29480. * Possible fallbacks for this effect to improve performance when needed.
  29481. */
  29482. fallbacks: Nullable<IEffectFallbacks>;
  29483. /**
  29484. * Callback that will be called when the shader is compiled.
  29485. */
  29486. onCompiled: Nullable<(effect: Effect) => void>;
  29487. /**
  29488. * Callback that will be called if an error occurs during shader compilation.
  29489. */
  29490. onError: Nullable<(effect: Effect, errors: string) => void>;
  29491. /**
  29492. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29493. */
  29494. indexParameters?: any;
  29495. /**
  29496. * Max number of lights that can be used in the shader.
  29497. */
  29498. maxSimultaneousLights?: number;
  29499. /**
  29500. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29501. */
  29502. transformFeedbackVaryings?: Nullable<string[]>;
  29503. }
  29504. /**
  29505. * Effect containing vertex and fragment shader that can be executed on an object.
  29506. */
  29507. export class Effect implements IDisposable {
  29508. /**
  29509. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29510. */
  29511. static ShadersRepository: string;
  29512. /**
  29513. * Name of the effect.
  29514. */
  29515. name: any;
  29516. /**
  29517. * String container all the define statements that should be set on the shader.
  29518. */
  29519. defines: string;
  29520. /**
  29521. * Callback that will be called when the shader is compiled.
  29522. */
  29523. onCompiled: Nullable<(effect: Effect) => void>;
  29524. /**
  29525. * Callback that will be called if an error occurs during shader compilation.
  29526. */
  29527. onError: Nullable<(effect: Effect, errors: string) => void>;
  29528. /**
  29529. * Callback that will be called when effect is bound.
  29530. */
  29531. onBind: Nullable<(effect: Effect) => void>;
  29532. /**
  29533. * Unique ID of the effect.
  29534. */
  29535. uniqueId: number;
  29536. /**
  29537. * Observable that will be called when the shader is compiled.
  29538. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29539. */
  29540. onCompileObservable: Observable<Effect>;
  29541. /**
  29542. * Observable that will be called if an error occurs during shader compilation.
  29543. */
  29544. onErrorObservable: Observable<Effect>;
  29545. /** @hidden */
  29546. _onBindObservable: Nullable<Observable<Effect>>;
  29547. /**
  29548. * Observable that will be called when effect is bound.
  29549. */
  29550. readonly onBindObservable: Observable<Effect>;
  29551. /** @hidden */
  29552. _bonesComputationForcedToCPU: boolean;
  29553. private static _uniqueIdSeed;
  29554. private _engine;
  29555. private _uniformBuffersNames;
  29556. private _uniformsNames;
  29557. private _samplerList;
  29558. private _samplers;
  29559. private _isReady;
  29560. private _compilationError;
  29561. private _allFallbacksProcessed;
  29562. private _attributesNames;
  29563. private _attributes;
  29564. private _attributeLocationByName;
  29565. private _uniforms;
  29566. /**
  29567. * Key for the effect.
  29568. * @hidden
  29569. */
  29570. _key: string;
  29571. private _indexParameters;
  29572. private _fallbacks;
  29573. private _vertexSourceCode;
  29574. private _fragmentSourceCode;
  29575. private _vertexSourceCodeOverride;
  29576. private _fragmentSourceCodeOverride;
  29577. private _transformFeedbackVaryings;
  29578. /**
  29579. * Compiled shader to webGL program.
  29580. * @hidden
  29581. */
  29582. _pipelineContext: Nullable<IPipelineContext>;
  29583. private _valueCache;
  29584. private static _baseCache;
  29585. /**
  29586. * Instantiates an effect.
  29587. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29588. * @param baseName Name of the effect.
  29589. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29590. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29591. * @param samplers List of sampler variables that will be passed to the shader.
  29592. * @param engine Engine to be used to render the effect
  29593. * @param defines Define statements to be added to the shader.
  29594. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29595. * @param onCompiled Callback that will be called when the shader is compiled.
  29596. * @param onError Callback that will be called if an error occurs during shader compilation.
  29597. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29598. */
  29599. 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);
  29600. private _useFinalCode;
  29601. /**
  29602. * Unique key for this effect
  29603. */
  29604. readonly key: string;
  29605. /**
  29606. * If the effect has been compiled and prepared.
  29607. * @returns if the effect is compiled and prepared.
  29608. */
  29609. isReady(): boolean;
  29610. private _isReadyInternal;
  29611. /**
  29612. * The engine the effect was initialized with.
  29613. * @returns the engine.
  29614. */
  29615. getEngine(): Engine;
  29616. /**
  29617. * The pipeline context for this effect
  29618. * @returns the associated pipeline context
  29619. */
  29620. getPipelineContext(): Nullable<IPipelineContext>;
  29621. /**
  29622. * The set of names of attribute variables for the shader.
  29623. * @returns An array of attribute names.
  29624. */
  29625. getAttributesNames(): string[];
  29626. /**
  29627. * Returns the attribute at the given index.
  29628. * @param index The index of the attribute.
  29629. * @returns The location of the attribute.
  29630. */
  29631. getAttributeLocation(index: number): number;
  29632. /**
  29633. * Returns the attribute based on the name of the variable.
  29634. * @param name of the attribute to look up.
  29635. * @returns the attribute location.
  29636. */
  29637. getAttributeLocationByName(name: string): number;
  29638. /**
  29639. * The number of attributes.
  29640. * @returns the numnber of attributes.
  29641. */
  29642. getAttributesCount(): number;
  29643. /**
  29644. * Gets the index of a uniform variable.
  29645. * @param uniformName of the uniform to look up.
  29646. * @returns the index.
  29647. */
  29648. getUniformIndex(uniformName: string): number;
  29649. /**
  29650. * Returns the attribute based on the name of the variable.
  29651. * @param uniformName of the uniform to look up.
  29652. * @returns the location of the uniform.
  29653. */
  29654. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29655. /**
  29656. * Returns an array of sampler variable names
  29657. * @returns The array of sampler variable neames.
  29658. */
  29659. getSamplers(): string[];
  29660. /**
  29661. * The error from the last compilation.
  29662. * @returns the error string.
  29663. */
  29664. getCompilationError(): string;
  29665. /**
  29666. * Gets a boolean indicating that all fallbacks were used during compilation
  29667. * @returns true if all fallbacks were used
  29668. */
  29669. allFallbacksProcessed(): boolean;
  29670. /**
  29671. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29672. * @param func The callback to be used.
  29673. */
  29674. executeWhenCompiled(func: (effect: Effect) => void): void;
  29675. private _checkIsReady;
  29676. private _loadShader;
  29677. /**
  29678. * Recompiles the webGL program
  29679. * @param vertexSourceCode The source code for the vertex shader.
  29680. * @param fragmentSourceCode The source code for the fragment shader.
  29681. * @param onCompiled Callback called when completed.
  29682. * @param onError Callback called on error.
  29683. * @hidden
  29684. */
  29685. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29686. /**
  29687. * Prepares the effect
  29688. * @hidden
  29689. */
  29690. _prepareEffect(): void;
  29691. private _processCompilationErrors;
  29692. /**
  29693. * Checks if the effect is supported. (Must be called after compilation)
  29694. */
  29695. readonly isSupported: boolean;
  29696. /**
  29697. * Binds a texture to the engine to be used as output of the shader.
  29698. * @param channel Name of the output variable.
  29699. * @param texture Texture to bind.
  29700. * @hidden
  29701. */
  29702. _bindTexture(channel: string, texture: InternalTexture): void;
  29703. /**
  29704. * Sets a texture on the engine to be used in the shader.
  29705. * @param channel Name of the sampler variable.
  29706. * @param texture Texture to set.
  29707. */
  29708. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29709. /**
  29710. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29711. * @param channel Name of the sampler variable.
  29712. * @param texture Texture to set.
  29713. */
  29714. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29715. /**
  29716. * Sets an array of textures on the engine to be used in the shader.
  29717. * @param channel Name of the variable.
  29718. * @param textures Textures to set.
  29719. */
  29720. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29721. /**
  29722. * 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)
  29723. * @param channel Name of the sampler variable.
  29724. * @param postProcess Post process to get the input texture from.
  29725. */
  29726. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29727. /**
  29728. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29729. * 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)
  29730. * @param channel Name of the sampler variable.
  29731. * @param postProcess Post process to get the output texture from.
  29732. */
  29733. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29734. /** @hidden */
  29735. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29736. /** @hidden */
  29737. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29738. /** @hidden */
  29739. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29740. /** @hidden */
  29741. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29742. /**
  29743. * Binds a buffer to a uniform.
  29744. * @param buffer Buffer to bind.
  29745. * @param name Name of the uniform variable to bind to.
  29746. */
  29747. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29748. /**
  29749. * Binds block to a uniform.
  29750. * @param blockName Name of the block to bind.
  29751. * @param index Index to bind.
  29752. */
  29753. bindUniformBlock(blockName: string, index: number): void;
  29754. /**
  29755. * Sets an interger value on a uniform variable.
  29756. * @param uniformName Name of the variable.
  29757. * @param value Value to be set.
  29758. * @returns this effect.
  29759. */
  29760. setInt(uniformName: string, value: number): Effect;
  29761. /**
  29762. * Sets an int array on a uniform variable.
  29763. * @param uniformName Name of the variable.
  29764. * @param array array to be set.
  29765. * @returns this effect.
  29766. */
  29767. setIntArray(uniformName: string, array: Int32Array): Effect;
  29768. /**
  29769. * 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)
  29770. * @param uniformName Name of the variable.
  29771. * @param array array to be set.
  29772. * @returns this effect.
  29773. */
  29774. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29775. /**
  29776. * 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)
  29777. * @param uniformName Name of the variable.
  29778. * @param array array to be set.
  29779. * @returns this effect.
  29780. */
  29781. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29782. /**
  29783. * 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)
  29784. * @param uniformName Name of the variable.
  29785. * @param array array to be set.
  29786. * @returns this effect.
  29787. */
  29788. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29789. /**
  29790. * Sets an float array on a uniform variable.
  29791. * @param uniformName Name of the variable.
  29792. * @param array array to be set.
  29793. * @returns this effect.
  29794. */
  29795. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29796. /**
  29797. * 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)
  29798. * @param uniformName Name of the variable.
  29799. * @param array array to be set.
  29800. * @returns this effect.
  29801. */
  29802. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29803. /**
  29804. * 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)
  29805. * @param uniformName Name of the variable.
  29806. * @param array array to be set.
  29807. * @returns this effect.
  29808. */
  29809. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29810. /**
  29811. * 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)
  29812. * @param uniformName Name of the variable.
  29813. * @param array array to be set.
  29814. * @returns this effect.
  29815. */
  29816. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29817. /**
  29818. * Sets an array on a uniform variable.
  29819. * @param uniformName Name of the variable.
  29820. * @param array array to be set.
  29821. * @returns this effect.
  29822. */
  29823. setArray(uniformName: string, array: number[]): Effect;
  29824. /**
  29825. * 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)
  29826. * @param uniformName Name of the variable.
  29827. * @param array array to be set.
  29828. * @returns this effect.
  29829. */
  29830. setArray2(uniformName: string, array: number[]): Effect;
  29831. /**
  29832. * 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)
  29833. * @param uniformName Name of the variable.
  29834. * @param array array to be set.
  29835. * @returns this effect.
  29836. */
  29837. setArray3(uniformName: string, array: number[]): Effect;
  29838. /**
  29839. * 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)
  29840. * @param uniformName Name of the variable.
  29841. * @param array array to be set.
  29842. * @returns this effect.
  29843. */
  29844. setArray4(uniformName: string, array: number[]): Effect;
  29845. /**
  29846. * Sets matrices on a uniform variable.
  29847. * @param uniformName Name of the variable.
  29848. * @param matrices matrices to be set.
  29849. * @returns this effect.
  29850. */
  29851. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29852. /**
  29853. * Sets matrix on a uniform variable.
  29854. * @param uniformName Name of the variable.
  29855. * @param matrix matrix to be set.
  29856. * @returns this effect.
  29857. */
  29858. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29859. /**
  29860. * 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)
  29861. * @param uniformName Name of the variable.
  29862. * @param matrix matrix to be set.
  29863. * @returns this effect.
  29864. */
  29865. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29866. /**
  29867. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29868. * @param uniformName Name of the variable.
  29869. * @param matrix matrix to be set.
  29870. * @returns this effect.
  29871. */
  29872. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29873. /**
  29874. * Sets a float on a uniform variable.
  29875. * @param uniformName Name of the variable.
  29876. * @param value value to be set.
  29877. * @returns this effect.
  29878. */
  29879. setFloat(uniformName: string, value: number): Effect;
  29880. /**
  29881. * Sets a boolean on a uniform variable.
  29882. * @param uniformName Name of the variable.
  29883. * @param bool value to be set.
  29884. * @returns this effect.
  29885. */
  29886. setBool(uniformName: string, bool: boolean): Effect;
  29887. /**
  29888. * Sets a Vector2 on a uniform variable.
  29889. * @param uniformName Name of the variable.
  29890. * @param vector2 vector2 to be set.
  29891. * @returns this effect.
  29892. */
  29893. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29894. /**
  29895. * Sets a float2 on a uniform variable.
  29896. * @param uniformName Name of the variable.
  29897. * @param x First float in float2.
  29898. * @param y Second float in float2.
  29899. * @returns this effect.
  29900. */
  29901. setFloat2(uniformName: string, x: number, y: number): Effect;
  29902. /**
  29903. * Sets a Vector3 on a uniform variable.
  29904. * @param uniformName Name of the variable.
  29905. * @param vector3 Value to be set.
  29906. * @returns this effect.
  29907. */
  29908. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29909. /**
  29910. * Sets a float3 on a uniform variable.
  29911. * @param uniformName Name of the variable.
  29912. * @param x First float in float3.
  29913. * @param y Second float in float3.
  29914. * @param z Third float in float3.
  29915. * @returns this effect.
  29916. */
  29917. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29918. /**
  29919. * Sets a Vector4 on a uniform variable.
  29920. * @param uniformName Name of the variable.
  29921. * @param vector4 Value to be set.
  29922. * @returns this effect.
  29923. */
  29924. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29925. /**
  29926. * Sets a float4 on a uniform variable.
  29927. * @param uniformName Name of the variable.
  29928. * @param x First float in float4.
  29929. * @param y Second float in float4.
  29930. * @param z Third float in float4.
  29931. * @param w Fourth float in float4.
  29932. * @returns this effect.
  29933. */
  29934. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29935. /**
  29936. * Sets a Color3 on a uniform variable.
  29937. * @param uniformName Name of the variable.
  29938. * @param color3 Value to be set.
  29939. * @returns this effect.
  29940. */
  29941. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29942. /**
  29943. * Sets a Color4 on a uniform variable.
  29944. * @param uniformName Name of the variable.
  29945. * @param color3 Value to be set.
  29946. * @param alpha Alpha value to be set.
  29947. * @returns this effect.
  29948. */
  29949. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29950. /**
  29951. * Sets a Color4 on a uniform variable
  29952. * @param uniformName defines the name of the variable
  29953. * @param color4 defines the value to be set
  29954. * @returns this effect.
  29955. */
  29956. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29957. /** Release all associated resources */
  29958. dispose(): void;
  29959. /**
  29960. * This function will add a new shader to the shader store
  29961. * @param name the name of the shader
  29962. * @param pixelShader optional pixel shader content
  29963. * @param vertexShader optional vertex shader content
  29964. */
  29965. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29966. /**
  29967. * Store of each shader (The can be looked up using effect.key)
  29968. */
  29969. static ShadersStore: {
  29970. [key: string]: string;
  29971. };
  29972. /**
  29973. * Store of each included file for a shader (The can be looked up using effect.key)
  29974. */
  29975. static IncludesShadersStore: {
  29976. [key: string]: string;
  29977. };
  29978. /**
  29979. * Resets the cache of effects.
  29980. */
  29981. static ResetCache(): void;
  29982. }
  29983. }
  29984. declare module BABYLON {
  29985. /**
  29986. * Interface used to describe the capabilities of the engine relatively to the current browser
  29987. */
  29988. export interface EngineCapabilities {
  29989. /** Maximum textures units per fragment shader */
  29990. maxTexturesImageUnits: number;
  29991. /** Maximum texture units per vertex shader */
  29992. maxVertexTextureImageUnits: number;
  29993. /** Maximum textures units in the entire pipeline */
  29994. maxCombinedTexturesImageUnits: number;
  29995. /** Maximum texture size */
  29996. maxTextureSize: number;
  29997. /** Maximum texture samples */
  29998. maxSamples?: number;
  29999. /** Maximum cube texture size */
  30000. maxCubemapTextureSize: number;
  30001. /** Maximum render texture size */
  30002. maxRenderTextureSize: number;
  30003. /** Maximum number of vertex attributes */
  30004. maxVertexAttribs: number;
  30005. /** Maximum number of varyings */
  30006. maxVaryingVectors: number;
  30007. /** Maximum number of uniforms per vertex shader */
  30008. maxVertexUniformVectors: number;
  30009. /** Maximum number of uniforms per fragment shader */
  30010. maxFragmentUniformVectors: number;
  30011. /** Defines if standard derivates (dx/dy) are supported */
  30012. standardDerivatives: boolean;
  30013. /** Defines if s3tc texture compression is supported */
  30014. s3tc?: WEBGL_compressed_texture_s3tc;
  30015. /** Defines if pvrtc texture compression is supported */
  30016. pvrtc: any;
  30017. /** Defines if etc1 texture compression is supported */
  30018. etc1: any;
  30019. /** Defines if etc2 texture compression is supported */
  30020. etc2: any;
  30021. /** Defines if astc texture compression is supported */
  30022. astc: any;
  30023. /** Defines if float textures are supported */
  30024. textureFloat: boolean;
  30025. /** Defines if vertex array objects are supported */
  30026. vertexArrayObject: boolean;
  30027. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30028. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30029. /** Gets the maximum level of anisotropy supported */
  30030. maxAnisotropy: number;
  30031. /** Defines if instancing is supported */
  30032. instancedArrays: boolean;
  30033. /** Defines if 32 bits indices are supported */
  30034. uintIndices: boolean;
  30035. /** Defines if high precision shaders are supported */
  30036. highPrecisionShaderSupported: boolean;
  30037. /** Defines if depth reading in the fragment shader is supported */
  30038. fragmentDepthSupported: boolean;
  30039. /** Defines if float texture linear filtering is supported*/
  30040. textureFloatLinearFiltering: boolean;
  30041. /** Defines if rendering to float textures is supported */
  30042. textureFloatRender: boolean;
  30043. /** Defines if half float textures are supported*/
  30044. textureHalfFloat: boolean;
  30045. /** Defines if half float texture linear filtering is supported*/
  30046. textureHalfFloatLinearFiltering: boolean;
  30047. /** Defines if rendering to half float textures is supported */
  30048. textureHalfFloatRender: boolean;
  30049. /** Defines if textureLOD shader command is supported */
  30050. textureLOD: boolean;
  30051. /** Defines if draw buffers extension is supported */
  30052. drawBuffersExtension: boolean;
  30053. /** Defines if depth textures are supported */
  30054. depthTextureExtension: boolean;
  30055. /** Defines if float color buffer are supported */
  30056. colorBufferFloat: boolean;
  30057. /** Gets disjoint timer query extension (null if not supported) */
  30058. timerQuery?: EXT_disjoint_timer_query;
  30059. /** Defines if timestamp can be used with timer query */
  30060. canUseTimestampForTimerQuery: boolean;
  30061. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30062. multiview?: any;
  30063. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30064. oculusMultiview?: any;
  30065. /** Function used to let the system compiles shaders in background */
  30066. parallelShaderCompile?: {
  30067. COMPLETION_STATUS_KHR: number;
  30068. };
  30069. /** Max number of texture samples for MSAA */
  30070. maxMSAASamples: number;
  30071. /** Defines if the blend min max extension is supported */
  30072. blendMinMax: boolean;
  30073. }
  30074. }
  30075. declare module BABYLON {
  30076. /**
  30077. * @hidden
  30078. **/
  30079. export class DepthCullingState {
  30080. private _isDepthTestDirty;
  30081. private _isDepthMaskDirty;
  30082. private _isDepthFuncDirty;
  30083. private _isCullFaceDirty;
  30084. private _isCullDirty;
  30085. private _isZOffsetDirty;
  30086. private _isFrontFaceDirty;
  30087. private _depthTest;
  30088. private _depthMask;
  30089. private _depthFunc;
  30090. private _cull;
  30091. private _cullFace;
  30092. private _zOffset;
  30093. private _frontFace;
  30094. /**
  30095. * Initializes the state.
  30096. */
  30097. constructor();
  30098. readonly isDirty: boolean;
  30099. zOffset: number;
  30100. cullFace: Nullable<number>;
  30101. cull: Nullable<boolean>;
  30102. depthFunc: Nullable<number>;
  30103. depthMask: boolean;
  30104. depthTest: boolean;
  30105. frontFace: Nullable<number>;
  30106. reset(): void;
  30107. apply(gl: WebGLRenderingContext): void;
  30108. }
  30109. }
  30110. declare module BABYLON {
  30111. /**
  30112. * @hidden
  30113. **/
  30114. export class StencilState {
  30115. /** 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 */
  30116. static readonly ALWAYS: number;
  30117. /** Passed to stencilOperation to specify that stencil value must be kept */
  30118. static readonly KEEP: number;
  30119. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30120. static readonly REPLACE: number;
  30121. private _isStencilTestDirty;
  30122. private _isStencilMaskDirty;
  30123. private _isStencilFuncDirty;
  30124. private _isStencilOpDirty;
  30125. private _stencilTest;
  30126. private _stencilMask;
  30127. private _stencilFunc;
  30128. private _stencilFuncRef;
  30129. private _stencilFuncMask;
  30130. private _stencilOpStencilFail;
  30131. private _stencilOpDepthFail;
  30132. private _stencilOpStencilDepthPass;
  30133. readonly isDirty: boolean;
  30134. stencilFunc: number;
  30135. stencilFuncRef: number;
  30136. stencilFuncMask: number;
  30137. stencilOpStencilFail: number;
  30138. stencilOpDepthFail: number;
  30139. stencilOpStencilDepthPass: number;
  30140. stencilMask: number;
  30141. stencilTest: boolean;
  30142. constructor();
  30143. reset(): void;
  30144. apply(gl: WebGLRenderingContext): void;
  30145. }
  30146. }
  30147. declare module BABYLON {
  30148. /**
  30149. * @hidden
  30150. **/
  30151. export class AlphaState {
  30152. private _isAlphaBlendDirty;
  30153. private _isBlendFunctionParametersDirty;
  30154. private _isBlendEquationParametersDirty;
  30155. private _isBlendConstantsDirty;
  30156. private _alphaBlend;
  30157. private _blendFunctionParameters;
  30158. private _blendEquationParameters;
  30159. private _blendConstants;
  30160. /**
  30161. * Initializes the state.
  30162. */
  30163. constructor();
  30164. readonly isDirty: boolean;
  30165. alphaBlend: boolean;
  30166. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30167. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30168. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30169. reset(): void;
  30170. apply(gl: WebGLRenderingContext): void;
  30171. }
  30172. }
  30173. declare module BABYLON {
  30174. /** @hidden */
  30175. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30176. attributeProcessor(attribute: string): string;
  30177. varyingProcessor(varying: string, isFragment: boolean): string;
  30178. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30179. }
  30180. }
  30181. declare module BABYLON {
  30182. /**
  30183. * Interface for attribute information associated with buffer instanciation
  30184. */
  30185. export interface InstancingAttributeInfo {
  30186. /**
  30187. * Name of the GLSL attribute
  30188. * if attribute index is not specified, this is used to retrieve the index from the effect
  30189. */
  30190. attributeName: string;
  30191. /**
  30192. * Index/offset of the attribute in the vertex shader
  30193. * if not specified, this will be computes from the name.
  30194. */
  30195. index?: number;
  30196. /**
  30197. * size of the attribute, 1, 2, 3 or 4
  30198. */
  30199. attributeSize: number;
  30200. /**
  30201. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30202. */
  30203. offset: number;
  30204. /**
  30205. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30206. * default to 1
  30207. */
  30208. divisor?: number;
  30209. /**
  30210. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30211. * default is FLOAT
  30212. */
  30213. attributeType?: number;
  30214. /**
  30215. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30216. */
  30217. normalized?: boolean;
  30218. }
  30219. }
  30220. declare module BABYLON {
  30221. interface ThinEngine {
  30222. /**
  30223. * Update a video texture
  30224. * @param texture defines the texture to update
  30225. * @param video defines the video element to use
  30226. * @param invertY defines if data must be stored with Y axis inverted
  30227. */
  30228. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30229. }
  30230. }
  30231. declare module BABYLON {
  30232. /**
  30233. * Settings for finer control over video usage
  30234. */
  30235. export interface VideoTextureSettings {
  30236. /**
  30237. * Applies `autoplay` to video, if specified
  30238. */
  30239. autoPlay?: boolean;
  30240. /**
  30241. * Applies `loop` to video, if specified
  30242. */
  30243. loop?: boolean;
  30244. /**
  30245. * Automatically updates internal texture from video at every frame in the render loop
  30246. */
  30247. autoUpdateTexture: boolean;
  30248. /**
  30249. * Image src displayed during the video loading or until the user interacts with the video.
  30250. */
  30251. poster?: string;
  30252. }
  30253. /**
  30254. * If you want to display a video in your scene, this is the special texture for that.
  30255. * This special texture works similar to other textures, with the exception of a few parameters.
  30256. * @see https://doc.babylonjs.com/how_to/video_texture
  30257. */
  30258. export class VideoTexture extends Texture {
  30259. /**
  30260. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30261. */
  30262. readonly autoUpdateTexture: boolean;
  30263. /**
  30264. * The video instance used by the texture internally
  30265. */
  30266. readonly video: HTMLVideoElement;
  30267. private _onUserActionRequestedObservable;
  30268. /**
  30269. * Event triggerd when a dom action is required by the user to play the video.
  30270. * This happens due to recent changes in browser policies preventing video to auto start.
  30271. */
  30272. readonly onUserActionRequestedObservable: Observable<Texture>;
  30273. private _generateMipMaps;
  30274. private _engine;
  30275. private _stillImageCaptured;
  30276. private _displayingPosterTexture;
  30277. private _settings;
  30278. private _createInternalTextureOnEvent;
  30279. private _frameId;
  30280. /**
  30281. * Creates a video texture.
  30282. * If you want to display a video in your scene, this is the special texture for that.
  30283. * This special texture works similar to other textures, with the exception of a few parameters.
  30284. * @see https://doc.babylonjs.com/how_to/video_texture
  30285. * @param name optional name, will detect from video source, if not defined
  30286. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30287. * @param scene is obviously the current scene.
  30288. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30289. * @param invertY is false by default but can be used to invert video on Y axis
  30290. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30291. * @param settings allows finer control over video usage
  30292. */
  30293. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30294. private _getName;
  30295. private _getVideo;
  30296. private _createInternalTexture;
  30297. private reset;
  30298. /**
  30299. * @hidden Internal method to initiate `update`.
  30300. */
  30301. _rebuild(): void;
  30302. /**
  30303. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30304. */
  30305. update(): void;
  30306. /**
  30307. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30308. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30309. */
  30310. updateTexture(isVisible: boolean): void;
  30311. protected _updateInternalTexture: () => void;
  30312. /**
  30313. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30314. * @param url New url.
  30315. */
  30316. updateURL(url: string): void;
  30317. /**
  30318. * Dispose the texture and release its associated resources.
  30319. */
  30320. dispose(): void;
  30321. /**
  30322. * Creates a video texture straight from a stream.
  30323. * @param scene Define the scene the texture should be created in
  30324. * @param stream Define the stream the texture should be created from
  30325. * @returns The created video texture as a promise
  30326. */
  30327. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30328. /**
  30329. * Creates a video texture straight from your WebCam video feed.
  30330. * @param scene Define the scene the texture should be created in
  30331. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30332. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30333. * @returns The created video texture as a promise
  30334. */
  30335. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30336. minWidth: number;
  30337. maxWidth: number;
  30338. minHeight: number;
  30339. maxHeight: number;
  30340. deviceId: string;
  30341. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30342. /**
  30343. * Creates a video texture straight from your WebCam video feed.
  30344. * @param scene Define the scene the texture should be created in
  30345. * @param onReady Define a callback to triggered once the texture will be ready
  30346. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30347. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30348. */
  30349. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30350. minWidth: number;
  30351. maxWidth: number;
  30352. minHeight: number;
  30353. maxHeight: number;
  30354. deviceId: string;
  30355. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30356. }
  30357. }
  30358. declare module BABYLON {
  30359. /**
  30360. * Defines the interface used by objects working like Scene
  30361. * @hidden
  30362. */
  30363. interface ISceneLike {
  30364. _addPendingData(data: any): void;
  30365. _removePendingData(data: any): void;
  30366. offlineProvider: IOfflineProvider;
  30367. }
  30368. /** Interface defining initialization parameters for Engine class */
  30369. export interface EngineOptions extends WebGLContextAttributes {
  30370. /**
  30371. * Defines if the engine should no exceed a specified device ratio
  30372. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30373. */
  30374. limitDeviceRatio?: number;
  30375. /**
  30376. * Defines if webvr should be enabled automatically
  30377. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30378. */
  30379. autoEnableWebVR?: boolean;
  30380. /**
  30381. * Defines if webgl2 should be turned off even if supported
  30382. * @see http://doc.babylonjs.com/features/webgl2
  30383. */
  30384. disableWebGL2Support?: boolean;
  30385. /**
  30386. * Defines if webaudio should be initialized as well
  30387. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30388. */
  30389. audioEngine?: boolean;
  30390. /**
  30391. * Defines if animations should run using a deterministic lock step
  30392. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30393. */
  30394. deterministicLockstep?: boolean;
  30395. /** Defines the maximum steps to use with deterministic lock step mode */
  30396. lockstepMaxSteps?: number;
  30397. /** Defines the seconds between each deterministic lock step */
  30398. timeStep?: number;
  30399. /**
  30400. * Defines that engine should ignore context lost events
  30401. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30402. */
  30403. doNotHandleContextLost?: boolean;
  30404. /**
  30405. * Defines that engine should ignore modifying touch action attribute and style
  30406. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30407. */
  30408. doNotHandleTouchAction?: boolean;
  30409. /**
  30410. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30411. */
  30412. useHighPrecisionFloats?: boolean;
  30413. }
  30414. /**
  30415. * The base engine class (root of all engines)
  30416. */
  30417. export class ThinEngine {
  30418. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30419. static ExceptionList: ({
  30420. key: string;
  30421. capture: string;
  30422. captureConstraint: number;
  30423. targets: string[];
  30424. } | {
  30425. key: string;
  30426. capture: null;
  30427. captureConstraint: null;
  30428. targets: string[];
  30429. })[];
  30430. /** @hidden */
  30431. static _TextureLoaders: IInternalTextureLoader[];
  30432. /**
  30433. * Returns the current npm package of the sdk
  30434. */
  30435. static readonly NpmPackage: string;
  30436. /**
  30437. * Returns the current version of the framework
  30438. */
  30439. static readonly Version: string;
  30440. /**
  30441. * Returns a string describing the current engine
  30442. */
  30443. readonly description: string;
  30444. /**
  30445. * Gets or sets the epsilon value used by collision engine
  30446. */
  30447. static CollisionsEpsilon: number;
  30448. /**
  30449. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30450. */
  30451. static ShadersRepository: string;
  30452. /**
  30453. * Gets or sets the textures that the engine should not attempt to load as compressed
  30454. */
  30455. protected _excludedCompressedTextures: string[];
  30456. /**
  30457. * Filters the compressed texture formats to only include
  30458. * files that are not included in the skippable list
  30459. *
  30460. * @param url the current extension
  30461. * @param textureFormatInUse the current compressed texture format
  30462. * @returns "format" string
  30463. */
  30464. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  30465. /** @hidden */
  30466. _shaderProcessor: IShaderProcessor;
  30467. /**
  30468. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30469. */
  30470. forcePOTTextures: boolean;
  30471. /**
  30472. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30473. */
  30474. isFullscreen: boolean;
  30475. /**
  30476. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30477. */
  30478. cullBackFaces: boolean;
  30479. /**
  30480. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30481. */
  30482. renderEvenInBackground: boolean;
  30483. /**
  30484. * Gets or sets a boolean indicating that cache can be kept between frames
  30485. */
  30486. preventCacheWipeBetweenFrames: boolean;
  30487. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30488. validateShaderPrograms: boolean;
  30489. /**
  30490. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30491. * This can provide greater z depth for distant objects.
  30492. */
  30493. useReverseDepthBuffer: boolean;
  30494. /**
  30495. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30496. */
  30497. disableUniformBuffers: boolean;
  30498. /** @hidden */
  30499. _uniformBuffers: UniformBuffer[];
  30500. /**
  30501. * Gets a boolean indicating that the engine supports uniform buffers
  30502. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30503. */
  30504. readonly supportsUniformBuffers: boolean;
  30505. /** @hidden */
  30506. _gl: WebGLRenderingContext;
  30507. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30508. protected _windowIsBackground: boolean;
  30509. protected _webGLVersion: number;
  30510. protected _creationOptions: EngineOptions;
  30511. protected _highPrecisionShadersAllowed: boolean;
  30512. /** @hidden */
  30513. readonly _shouldUseHighPrecisionShader: boolean;
  30514. /**
  30515. * Gets a boolean indicating that only power of 2 textures are supported
  30516. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30517. */
  30518. readonly needPOTTextures: boolean;
  30519. /** @hidden */
  30520. _badOS: boolean;
  30521. /** @hidden */
  30522. _badDesktopOS: boolean;
  30523. private _hardwareScalingLevel;
  30524. /** @hidden */
  30525. _caps: EngineCapabilities;
  30526. private _isStencilEnable;
  30527. private _glVersion;
  30528. private _glRenderer;
  30529. private _glVendor;
  30530. /** @hidden */
  30531. _videoTextureSupported: boolean;
  30532. protected _renderingQueueLaunched: boolean;
  30533. protected _activeRenderLoops: (() => void)[];
  30534. /**
  30535. * Observable signaled when a context lost event is raised
  30536. */
  30537. onContextLostObservable: Observable<ThinEngine>;
  30538. /**
  30539. * Observable signaled when a context restored event is raised
  30540. */
  30541. onContextRestoredObservable: Observable<ThinEngine>;
  30542. private _onContextLost;
  30543. private _onContextRestored;
  30544. protected _contextWasLost: boolean;
  30545. /** @hidden */
  30546. _doNotHandleContextLost: boolean;
  30547. /**
  30548. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30549. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30550. */
  30551. doNotHandleContextLost: boolean;
  30552. /**
  30553. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30554. */
  30555. disableVertexArrayObjects: boolean;
  30556. /** @hidden */
  30557. protected _colorWrite: boolean;
  30558. /** @hidden */
  30559. protected _colorWriteChanged: boolean;
  30560. /** @hidden */
  30561. protected _depthCullingState: DepthCullingState;
  30562. /** @hidden */
  30563. protected _stencilState: StencilState;
  30564. /** @hidden */
  30565. _alphaState: AlphaState;
  30566. /** @hidden */
  30567. _alphaMode: number;
  30568. /** @hidden */
  30569. _alphaEquation: number;
  30570. /** @hidden */
  30571. _internalTexturesCache: InternalTexture[];
  30572. /** @hidden */
  30573. protected _activeChannel: number;
  30574. private _currentTextureChannel;
  30575. /** @hidden */
  30576. protected _boundTexturesCache: {
  30577. [key: string]: Nullable<InternalTexture>;
  30578. };
  30579. /** @hidden */
  30580. protected _currentEffect: Nullable<Effect>;
  30581. /** @hidden */
  30582. protected _currentProgram: Nullable<WebGLProgram>;
  30583. private _compiledEffects;
  30584. private _vertexAttribArraysEnabled;
  30585. /** @hidden */
  30586. protected _cachedViewport: Nullable<IViewportLike>;
  30587. private _cachedVertexArrayObject;
  30588. /** @hidden */
  30589. protected _cachedVertexBuffers: any;
  30590. /** @hidden */
  30591. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30592. /** @hidden */
  30593. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30594. /** @hidden */
  30595. _currentRenderTarget: Nullable<InternalTexture>;
  30596. private _uintIndicesCurrentlySet;
  30597. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30598. /** @hidden */
  30599. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30600. private _currentBufferPointers;
  30601. private _currentInstanceLocations;
  30602. private _currentInstanceBuffers;
  30603. private _textureUnits;
  30604. /** @hidden */
  30605. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30606. /** @hidden */
  30607. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30608. /** @hidden */
  30609. _boundRenderFunction: any;
  30610. private _vaoRecordInProgress;
  30611. private _mustWipeVertexAttributes;
  30612. private _emptyTexture;
  30613. private _emptyCubeTexture;
  30614. private _emptyTexture3D;
  30615. private _emptyTexture2DArray;
  30616. /** @hidden */
  30617. _frameHandler: number;
  30618. private _nextFreeTextureSlots;
  30619. private _maxSimultaneousTextures;
  30620. private _activeRequests;
  30621. protected _texturesSupported: string[];
  30622. /** @hidden */
  30623. _textureFormatInUse: Nullable<string>;
  30624. protected readonly _supportsHardwareTextureRescaling: boolean;
  30625. /**
  30626. * Gets the list of texture formats supported
  30627. */
  30628. readonly texturesSupported: Array<string>;
  30629. /**
  30630. * Gets the list of texture formats in use
  30631. */
  30632. readonly textureFormatInUse: Nullable<string>;
  30633. /**
  30634. * Gets the current viewport
  30635. */
  30636. readonly currentViewport: Nullable<IViewportLike>;
  30637. /**
  30638. * Gets the default empty texture
  30639. */
  30640. readonly emptyTexture: InternalTexture;
  30641. /**
  30642. * Gets the default empty 3D texture
  30643. */
  30644. readonly emptyTexture3D: InternalTexture;
  30645. /**
  30646. * Gets the default empty 2D array texture
  30647. */
  30648. readonly emptyTexture2DArray: InternalTexture;
  30649. /**
  30650. * Gets the default empty cube texture
  30651. */
  30652. readonly emptyCubeTexture: InternalTexture;
  30653. /**
  30654. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30655. */
  30656. readonly premultipliedAlpha: boolean;
  30657. /**
  30658. * Observable event triggered before each texture is initialized
  30659. */
  30660. onBeforeTextureInitObservable: Observable<Texture>;
  30661. /**
  30662. * Creates a new engine
  30663. * @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
  30664. * @param antialias defines enable antialiasing (default: false)
  30665. * @param options defines further options to be sent to the getContext() function
  30666. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30667. */
  30668. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30669. private _rebuildInternalTextures;
  30670. private _rebuildEffects;
  30671. /**
  30672. * Gets a boolean indicating if all created effects are ready
  30673. * @returns true if all effects are ready
  30674. */
  30675. areAllEffectsReady(): boolean;
  30676. protected _rebuildBuffers(): void;
  30677. private _initGLContext;
  30678. /**
  30679. * Gets version of the current webGL context
  30680. */
  30681. readonly webGLVersion: number;
  30682. /**
  30683. * Gets a string idenfifying the name of the class
  30684. * @returns "Engine" string
  30685. */
  30686. getClassName(): string;
  30687. /**
  30688. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30689. */
  30690. readonly isStencilEnable: boolean;
  30691. /** @hidden */
  30692. _prepareWorkingCanvas(): void;
  30693. /**
  30694. * Reset the texture cache to empty state
  30695. */
  30696. resetTextureCache(): void;
  30697. /**
  30698. * Gets an object containing information about the current webGL context
  30699. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30700. */
  30701. getGlInfo(): {
  30702. vendor: string;
  30703. renderer: string;
  30704. version: string;
  30705. };
  30706. /**
  30707. * Defines the hardware scaling level.
  30708. * By default the hardware scaling level is computed from the window device ratio.
  30709. * 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.
  30710. * @param level defines the level to use
  30711. */
  30712. setHardwareScalingLevel(level: number): void;
  30713. /**
  30714. * Gets the current hardware scaling level.
  30715. * By default the hardware scaling level is computed from the window device ratio.
  30716. * 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.
  30717. * @returns a number indicating the current hardware scaling level
  30718. */
  30719. getHardwareScalingLevel(): number;
  30720. /**
  30721. * Gets the list of loaded textures
  30722. * @returns an array containing all loaded textures
  30723. */
  30724. getLoadedTexturesCache(): InternalTexture[];
  30725. /**
  30726. * Gets the object containing all engine capabilities
  30727. * @returns the EngineCapabilities object
  30728. */
  30729. getCaps(): EngineCapabilities;
  30730. /**
  30731. * stop executing a render loop function and remove it from the execution array
  30732. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30733. */
  30734. stopRenderLoop(renderFunction?: () => void): void;
  30735. /** @hidden */
  30736. _renderLoop(): void;
  30737. /**
  30738. * Gets the HTML canvas attached with the current webGL context
  30739. * @returns a HTML canvas
  30740. */
  30741. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30742. /**
  30743. * Gets host window
  30744. * @returns the host window object
  30745. */
  30746. getHostWindow(): Nullable<Window>;
  30747. /**
  30748. * Gets the current render width
  30749. * @param useScreen defines if screen size must be used (or the current render target if any)
  30750. * @returns a number defining the current render width
  30751. */
  30752. getRenderWidth(useScreen?: boolean): number;
  30753. /**
  30754. * Gets the current render height
  30755. * @param useScreen defines if screen size must be used (or the current render target if any)
  30756. * @returns a number defining the current render height
  30757. */
  30758. getRenderHeight(useScreen?: boolean): number;
  30759. /**
  30760. * Can be used to override the current requestAnimationFrame requester.
  30761. * @hidden
  30762. */
  30763. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30764. /**
  30765. * Register and execute a render loop. The engine can have more than one render function
  30766. * @param renderFunction defines the function to continuously execute
  30767. */
  30768. runRenderLoop(renderFunction: () => void): void;
  30769. /**
  30770. * Clear the current render buffer or the current render target (if any is set up)
  30771. * @param color defines the color to use
  30772. * @param backBuffer defines if the back buffer must be cleared
  30773. * @param depth defines if the depth buffer must be cleared
  30774. * @param stencil defines if the stencil buffer must be cleared
  30775. */
  30776. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30777. private _viewportCached;
  30778. /** @hidden */
  30779. _viewport(x: number, y: number, width: number, height: number): void;
  30780. /**
  30781. * Set the WebGL's viewport
  30782. * @param viewport defines the viewport element to be used
  30783. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30784. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30785. */
  30786. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30787. /**
  30788. * Begin a new frame
  30789. */
  30790. beginFrame(): void;
  30791. /**
  30792. * Enf the current frame
  30793. */
  30794. endFrame(): void;
  30795. /**
  30796. * Resize the view according to the canvas' size
  30797. */
  30798. resize(): void;
  30799. /**
  30800. * Force a specific size of the canvas
  30801. * @param width defines the new canvas' width
  30802. * @param height defines the new canvas' height
  30803. */
  30804. setSize(width: number, height: number): void;
  30805. /**
  30806. * Binds the frame buffer to the specified texture.
  30807. * @param texture The texture to render to or null for the default canvas
  30808. * @param faceIndex The face of the texture to render to in case of cube texture
  30809. * @param requiredWidth The width of the target to render to
  30810. * @param requiredHeight The height of the target to render to
  30811. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30812. * @param depthStencilTexture The depth stencil texture to use to render
  30813. * @param lodLevel defines le lod level to bind to the frame buffer
  30814. */
  30815. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30816. /** @hidden */
  30817. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30818. /**
  30819. * Unbind the current render target texture from the webGL context
  30820. * @param texture defines the render target texture to unbind
  30821. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30822. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30823. */
  30824. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30825. /**
  30826. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30827. */
  30828. flushFramebuffer(): void;
  30829. /**
  30830. * Unbind the current render target and bind the default framebuffer
  30831. */
  30832. restoreDefaultFramebuffer(): void;
  30833. /** @hidden */
  30834. protected _resetVertexBufferBinding(): void;
  30835. /**
  30836. * Creates a vertex buffer
  30837. * @param data the data for the vertex buffer
  30838. * @returns the new WebGL static buffer
  30839. */
  30840. createVertexBuffer(data: DataArray): DataBuffer;
  30841. private _createVertexBuffer;
  30842. /**
  30843. * Creates a dynamic vertex buffer
  30844. * @param data the data for the dynamic vertex buffer
  30845. * @returns the new WebGL dynamic buffer
  30846. */
  30847. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30848. protected _resetIndexBufferBinding(): void;
  30849. /**
  30850. * Creates a new index buffer
  30851. * @param indices defines the content of the index buffer
  30852. * @param updatable defines if the index buffer must be updatable
  30853. * @returns a new webGL buffer
  30854. */
  30855. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30856. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30857. /**
  30858. * Bind a webGL buffer to the webGL context
  30859. * @param buffer defines the buffer to bind
  30860. */
  30861. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30862. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30863. private bindBuffer;
  30864. /**
  30865. * update the bound buffer with the given data
  30866. * @param data defines the data to update
  30867. */
  30868. updateArrayBuffer(data: Float32Array): void;
  30869. private _vertexAttribPointer;
  30870. private _bindIndexBufferWithCache;
  30871. private _bindVertexBuffersAttributes;
  30872. /**
  30873. * Records a vertex array object
  30874. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30875. * @param vertexBuffers defines the list of vertex buffers to store
  30876. * @param indexBuffer defines the index buffer to store
  30877. * @param effect defines the effect to store
  30878. * @returns the new vertex array object
  30879. */
  30880. recordVertexArrayObject(vertexBuffers: {
  30881. [key: string]: VertexBuffer;
  30882. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30883. /**
  30884. * Bind a specific vertex array object
  30885. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30886. * @param vertexArrayObject defines the vertex array object to bind
  30887. * @param indexBuffer defines the index buffer to bind
  30888. */
  30889. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30890. /**
  30891. * Bind webGl buffers directly to the webGL context
  30892. * @param vertexBuffer defines the vertex buffer to bind
  30893. * @param indexBuffer defines the index buffer to bind
  30894. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30895. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30896. * @param effect defines the effect associated with the vertex buffer
  30897. */
  30898. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30899. private _unbindVertexArrayObject;
  30900. /**
  30901. * Bind a list of vertex buffers to the webGL context
  30902. * @param vertexBuffers defines the list of vertex buffers to bind
  30903. * @param indexBuffer defines the index buffer to bind
  30904. * @param effect defines the effect associated with the vertex buffers
  30905. */
  30906. bindBuffers(vertexBuffers: {
  30907. [key: string]: Nullable<VertexBuffer>;
  30908. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30909. /**
  30910. * Unbind all instance attributes
  30911. */
  30912. unbindInstanceAttributes(): void;
  30913. /**
  30914. * Release and free the memory of a vertex array object
  30915. * @param vao defines the vertex array object to delete
  30916. */
  30917. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30918. /** @hidden */
  30919. _releaseBuffer(buffer: DataBuffer): boolean;
  30920. protected _deleteBuffer(buffer: DataBuffer): void;
  30921. /**
  30922. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30923. * @param instancesBuffer defines the webGL buffer to update and bind
  30924. * @param data defines the data to store in the buffer
  30925. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30926. */
  30927. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30928. /**
  30929. * Bind the content of a webGL buffer used with instanciation
  30930. * @param instancesBuffer defines the webGL buffer to bind
  30931. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  30932. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  30933. */
  30934. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  30935. /**
  30936. * Disable the instance attribute corresponding to the name in parameter
  30937. * @param name defines the name of the attribute to disable
  30938. */
  30939. disableInstanceAttributeByName(name: string): void;
  30940. /**
  30941. * Disable the instance attribute corresponding to the location in parameter
  30942. * @param attributeLocation defines the attribute location of the attribute to disable
  30943. */
  30944. disableInstanceAttribute(attributeLocation: number): void;
  30945. /**
  30946. * Disable the attribute corresponding to the location in parameter
  30947. * @param attributeLocation defines the attribute location of the attribute to disable
  30948. */
  30949. disableAttributeByIndex(attributeLocation: number): void;
  30950. /**
  30951. * Send a draw order
  30952. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30953. * @param indexStart defines the starting index
  30954. * @param indexCount defines the number of index to draw
  30955. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30956. */
  30957. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30958. /**
  30959. * Draw a list of points
  30960. * @param verticesStart defines the index of first vertex to draw
  30961. * @param verticesCount defines the count of vertices to draw
  30962. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30963. */
  30964. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30965. /**
  30966. * Draw a list of unindexed primitives
  30967. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30968. * @param verticesStart defines the index of first vertex to draw
  30969. * @param verticesCount defines the count of vertices to draw
  30970. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30971. */
  30972. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30973. /**
  30974. * Draw a list of indexed primitives
  30975. * @param fillMode defines the primitive to use
  30976. * @param indexStart defines the starting index
  30977. * @param indexCount defines the number of index to draw
  30978. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30979. */
  30980. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30981. /**
  30982. * Draw a list of unindexed primitives
  30983. * @param fillMode defines the primitive to use
  30984. * @param verticesStart defines the index of first vertex to draw
  30985. * @param verticesCount defines the count of vertices to draw
  30986. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30987. */
  30988. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30989. private _drawMode;
  30990. /** @hidden */
  30991. protected _reportDrawCall(): void;
  30992. /** @hidden */
  30993. _releaseEffect(effect: Effect): void;
  30994. /** @hidden */
  30995. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30996. /**
  30997. * Create a new effect (used to store vertex/fragment shaders)
  30998. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30999. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31000. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31001. * @param samplers defines an array of string used to represent textures
  31002. * @param defines defines the string containing the defines to use to compile the shaders
  31003. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31004. * @param onCompiled defines a function to call when the effect creation is successful
  31005. * @param onError defines a function to call when the effect creation has failed
  31006. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31007. * @returns the new Effect
  31008. */
  31009. 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;
  31010. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31011. private _compileShader;
  31012. private _compileRawShader;
  31013. /**
  31014. * Directly creates a webGL program
  31015. * @param pipelineContext defines the pipeline context to attach to
  31016. * @param vertexCode defines the vertex shader code to use
  31017. * @param fragmentCode defines the fragment shader code to use
  31018. * @param context defines the webGL context to use (if not set, the current one will be used)
  31019. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31020. * @returns the new webGL program
  31021. */
  31022. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31023. /**
  31024. * Creates a webGL program
  31025. * @param pipelineContext defines the pipeline context to attach to
  31026. * @param vertexCode defines the vertex shader code to use
  31027. * @param fragmentCode defines the fragment shader code to use
  31028. * @param defines defines the string containing the defines to use to compile the shaders
  31029. * @param context defines the webGL context to use (if not set, the current one will be used)
  31030. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31031. * @returns the new webGL program
  31032. */
  31033. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31034. /**
  31035. * Creates a new pipeline context
  31036. * @returns the new pipeline
  31037. */
  31038. createPipelineContext(): IPipelineContext;
  31039. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31040. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31041. /** @hidden */
  31042. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31043. /** @hidden */
  31044. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31045. /** @hidden */
  31046. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31047. /**
  31048. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31049. * @param pipelineContext defines the pipeline context to use
  31050. * @param uniformsNames defines the list of uniform names
  31051. * @returns an array of webGL uniform locations
  31052. */
  31053. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31054. /**
  31055. * Gets the lsit of active attributes for a given webGL program
  31056. * @param pipelineContext defines the pipeline context to use
  31057. * @param attributesNames defines the list of attribute names to get
  31058. * @returns an array of indices indicating the offset of each attribute
  31059. */
  31060. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31061. /**
  31062. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31063. * @param effect defines the effect to activate
  31064. */
  31065. enableEffect(effect: Nullable<Effect>): void;
  31066. /**
  31067. * Set the value of an uniform to a number (int)
  31068. * @param uniform defines the webGL uniform location where to store the value
  31069. * @param value defines the int number to store
  31070. */
  31071. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31072. /**
  31073. * Set the value of an uniform to an array of int32
  31074. * @param uniform defines the webGL uniform location where to store the value
  31075. * @param array defines the array of int32 to store
  31076. */
  31077. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31078. /**
  31079. * Set the value of an uniform to an array of int32 (stored as vec2)
  31080. * @param uniform defines the webGL uniform location where to store the value
  31081. * @param array defines the array of int32 to store
  31082. */
  31083. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31084. /**
  31085. * Set the value of an uniform to an array of int32 (stored as vec3)
  31086. * @param uniform defines the webGL uniform location where to store the value
  31087. * @param array defines the array of int32 to store
  31088. */
  31089. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31090. /**
  31091. * Set the value of an uniform to an array of int32 (stored as vec4)
  31092. * @param uniform defines the webGL uniform location where to store the value
  31093. * @param array defines the array of int32 to store
  31094. */
  31095. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31096. /**
  31097. * Set the value of an uniform to an array of number
  31098. * @param uniform defines the webGL uniform location where to store the value
  31099. * @param array defines the array of number to store
  31100. */
  31101. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31102. /**
  31103. * Set the value of an uniform to an array of number (stored as vec2)
  31104. * @param uniform defines the webGL uniform location where to store the value
  31105. * @param array defines the array of number to store
  31106. */
  31107. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31108. /**
  31109. * Set the value of an uniform to an array of number (stored as vec3)
  31110. * @param uniform defines the webGL uniform location where to store the value
  31111. * @param array defines the array of number to store
  31112. */
  31113. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31114. /**
  31115. * Set the value of an uniform to an array of number (stored as vec4)
  31116. * @param uniform defines the webGL uniform location where to store the value
  31117. * @param array defines the array of number to store
  31118. */
  31119. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31120. /**
  31121. * Set the value of an uniform to an array of float32 (stored as matrices)
  31122. * @param uniform defines the webGL uniform location where to store the value
  31123. * @param matrices defines the array of float32 to store
  31124. */
  31125. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31126. /**
  31127. * Set the value of an uniform to a matrix (3x3)
  31128. * @param uniform defines the webGL uniform location where to store the value
  31129. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31130. */
  31131. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31132. /**
  31133. * Set the value of an uniform to a matrix (2x2)
  31134. * @param uniform defines the webGL uniform location where to store the value
  31135. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31136. */
  31137. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31138. /**
  31139. * Set the value of an uniform to a number (float)
  31140. * @param uniform defines the webGL uniform location where to store the value
  31141. * @param value defines the float number to store
  31142. */
  31143. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31144. /**
  31145. * Set the value of an uniform to a vec2
  31146. * @param uniform defines the webGL uniform location where to store the value
  31147. * @param x defines the 1st component of the value
  31148. * @param y defines the 2nd component of the value
  31149. */
  31150. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31151. /**
  31152. * Set the value of an uniform to a vec3
  31153. * @param uniform defines the webGL uniform location where to store the value
  31154. * @param x defines the 1st component of the value
  31155. * @param y defines the 2nd component of the value
  31156. * @param z defines the 3rd component of the value
  31157. */
  31158. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31159. /**
  31160. * Set the value of an uniform to a vec4
  31161. * @param uniform defines the webGL uniform location where to store the value
  31162. * @param x defines the 1st component of the value
  31163. * @param y defines the 2nd component of the value
  31164. * @param z defines the 3rd component of the value
  31165. * @param w defines the 4th component of the value
  31166. */
  31167. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31168. /**
  31169. * Apply all cached states (depth, culling, stencil and alpha)
  31170. */
  31171. applyStates(): void;
  31172. /**
  31173. * Enable or disable color writing
  31174. * @param enable defines the state to set
  31175. */
  31176. setColorWrite(enable: boolean): void;
  31177. /**
  31178. * Gets a boolean indicating if color writing is enabled
  31179. * @returns the current color writing state
  31180. */
  31181. getColorWrite(): boolean;
  31182. /**
  31183. * Gets the depth culling state manager
  31184. */
  31185. readonly depthCullingState: DepthCullingState;
  31186. /**
  31187. * Gets the alpha state manager
  31188. */
  31189. readonly alphaState: AlphaState;
  31190. /**
  31191. * Gets the stencil state manager
  31192. */
  31193. readonly stencilState: StencilState;
  31194. /**
  31195. * Clears the list of texture accessible through engine.
  31196. * This can help preventing texture load conflict due to name collision.
  31197. */
  31198. clearInternalTexturesCache(): void;
  31199. /**
  31200. * Force the entire cache to be cleared
  31201. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31202. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31203. */
  31204. wipeCaches(bruteForce?: boolean): void;
  31205. /** @hidden */
  31206. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31207. min: number;
  31208. mag: number;
  31209. };
  31210. /** @hidden */
  31211. _createTexture(): WebGLTexture;
  31212. /**
  31213. * Usually called from Texture.ts.
  31214. * Passed information to create a WebGLTexture
  31215. * @param urlArg defines a value which contains one of the following:
  31216. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31217. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31218. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31219. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31220. * @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)
  31221. * @param scene needed for loading to the correct scene
  31222. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31223. * @param onLoad optional callback to be called upon successful completion
  31224. * @param onError optional callback to be called upon failure
  31225. * @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
  31226. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31227. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31228. * @param forcedExtension defines the extension to use to pick the right loader
  31229. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31230. * @param mimeType defines an optional mime type
  31231. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31232. */
  31233. 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;
  31234. /**
  31235. * @hidden
  31236. */
  31237. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31238. /**
  31239. * Creates a raw texture
  31240. * @param data defines the data to store in the texture
  31241. * @param width defines the width of the texture
  31242. * @param height defines the height of the texture
  31243. * @param format defines the format of the data
  31244. * @param generateMipMaps defines if the engine should generate the mip levels
  31245. * @param invertY defines if data must be stored with Y axis inverted
  31246. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31247. * @param compression defines the compression used (null by default)
  31248. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31249. * @returns the raw texture inside an InternalTexture
  31250. */
  31251. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31252. /**
  31253. * Creates a new raw cube texture
  31254. * @param data defines the array of data to use to create each face
  31255. * @param size defines the size of the textures
  31256. * @param format defines the format of the data
  31257. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31258. * @param generateMipMaps defines if the engine should generate the mip levels
  31259. * @param invertY defines if data must be stored with Y axis inverted
  31260. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31261. * @param compression defines the compression used (null by default)
  31262. * @returns the cube texture as an InternalTexture
  31263. */
  31264. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31265. /**
  31266. * Creates a new raw 3D texture
  31267. * @param data defines the data used to create the texture
  31268. * @param width defines the width of the texture
  31269. * @param height defines the height of the texture
  31270. * @param depth defines the depth of the texture
  31271. * @param format defines the format of the texture
  31272. * @param generateMipMaps defines if the engine must generate mip levels
  31273. * @param invertY defines if data must be stored with Y axis inverted
  31274. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31275. * @param compression defines the compressed used (can be null)
  31276. * @param textureType defines the compressed used (can be null)
  31277. * @returns a new raw 3D texture (stored in an InternalTexture)
  31278. */
  31279. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31280. /**
  31281. * Creates a new raw 2D array texture
  31282. * @param data defines the data used to create the texture
  31283. * @param width defines the width of the texture
  31284. * @param height defines the height of the texture
  31285. * @param depth defines the number of layers of the texture
  31286. * @param format defines the format of the texture
  31287. * @param generateMipMaps defines if the engine must generate mip levels
  31288. * @param invertY defines if data must be stored with Y axis inverted
  31289. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31290. * @param compression defines the compressed used (can be null)
  31291. * @param textureType defines the compressed used (can be null)
  31292. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31293. */
  31294. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31295. private _unpackFlipYCached;
  31296. /**
  31297. * In case you are sharing the context with other applications, it might
  31298. * be interested to not cache the unpack flip y state to ensure a consistent
  31299. * value would be set.
  31300. */
  31301. enableUnpackFlipYCached: boolean;
  31302. /** @hidden */
  31303. _unpackFlipY(value: boolean): void;
  31304. /** @hidden */
  31305. _getUnpackAlignement(): number;
  31306. /**
  31307. * Update the sampling mode of a given texture
  31308. * @param samplingMode defines the required sampling mode
  31309. * @param texture defines the texture to update
  31310. */
  31311. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31312. /** @hidden */
  31313. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31314. width: number;
  31315. height: number;
  31316. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31317. /** @hidden */
  31318. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31319. /** @hidden */
  31320. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31321. /** @hidden */
  31322. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31323. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31324. private _prepareWebGLTexture;
  31325. /** @hidden */
  31326. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31327. private _getDepthStencilBuffer;
  31328. /** @hidden */
  31329. _releaseFramebufferObjects(texture: InternalTexture): void;
  31330. /** @hidden */
  31331. _releaseTexture(texture: InternalTexture): void;
  31332. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31333. protected _setProgram(program: WebGLProgram): void;
  31334. protected _boundUniforms: {
  31335. [key: number]: WebGLUniformLocation;
  31336. };
  31337. /**
  31338. * Binds an effect to the webGL context
  31339. * @param effect defines the effect to bind
  31340. */
  31341. bindSamplers(effect: Effect): void;
  31342. private _activateCurrentTexture;
  31343. /** @hidden */
  31344. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31345. /** @hidden */
  31346. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31347. /**
  31348. * Unbind all textures from the webGL context
  31349. */
  31350. unbindAllTextures(): void;
  31351. /**
  31352. * Sets a texture to the according uniform.
  31353. * @param channel The texture channel
  31354. * @param uniform The uniform to set
  31355. * @param texture The texture to apply
  31356. */
  31357. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31358. private _bindSamplerUniformToChannel;
  31359. private _getTextureWrapMode;
  31360. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31361. /**
  31362. * Sets an array of texture to the webGL context
  31363. * @param channel defines the channel where the texture array must be set
  31364. * @param uniform defines the associated uniform location
  31365. * @param textures defines the array of textures to bind
  31366. */
  31367. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31368. /** @hidden */
  31369. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31370. private _setTextureParameterFloat;
  31371. private _setTextureParameterInteger;
  31372. /**
  31373. * Unbind all vertex attributes from the webGL context
  31374. */
  31375. unbindAllAttributes(): void;
  31376. /**
  31377. * 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
  31378. */
  31379. releaseEffects(): void;
  31380. /**
  31381. * Dispose and release all associated resources
  31382. */
  31383. dispose(): void;
  31384. /**
  31385. * Attach a new callback raised when context lost event is fired
  31386. * @param callback defines the callback to call
  31387. */
  31388. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31389. /**
  31390. * Attach a new callback raised when context restored event is fired
  31391. * @param callback defines the callback to call
  31392. */
  31393. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31394. /**
  31395. * Get the current error code of the webGL context
  31396. * @returns the error code
  31397. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31398. */
  31399. getError(): number;
  31400. private _canRenderToFloatFramebuffer;
  31401. private _canRenderToHalfFloatFramebuffer;
  31402. private _canRenderToFramebuffer;
  31403. /** @hidden */
  31404. _getWebGLTextureType(type: number): number;
  31405. /** @hidden */
  31406. _getInternalFormat(format: number): number;
  31407. /** @hidden */
  31408. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31409. /** @hidden */
  31410. _getRGBAMultiSampleBufferFormat(type: number): number;
  31411. /** @hidden */
  31412. _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;
  31413. /**
  31414. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31415. * @returns true if the engine can be created
  31416. * @ignorenaming
  31417. */
  31418. static isSupported(): boolean;
  31419. /**
  31420. * Find the next highest power of two.
  31421. * @param x Number to start search from.
  31422. * @return Next highest power of two.
  31423. */
  31424. static CeilingPOT(x: number): number;
  31425. /**
  31426. * Find the next lowest power of two.
  31427. * @param x Number to start search from.
  31428. * @return Next lowest power of two.
  31429. */
  31430. static FloorPOT(x: number): number;
  31431. /**
  31432. * Find the nearest power of two.
  31433. * @param x Number to start search from.
  31434. * @return Next nearest power of two.
  31435. */
  31436. static NearestPOT(x: number): number;
  31437. /**
  31438. * Get the closest exponent of two
  31439. * @param value defines the value to approximate
  31440. * @param max defines the maximum value to return
  31441. * @param mode defines how to define the closest value
  31442. * @returns closest exponent of two of the given value
  31443. */
  31444. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31445. /**
  31446. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31447. * @param func - the function to be called
  31448. * @param requester - the object that will request the next frame. Falls back to window.
  31449. * @returns frame number
  31450. */
  31451. static QueueNewFrame(func: () => void, requester?: any): number;
  31452. /**
  31453. * Gets host document
  31454. * @returns the host document object
  31455. */
  31456. getHostDocument(): Document;
  31457. }
  31458. }
  31459. declare module BABYLON {
  31460. /**
  31461. * Class representing spherical harmonics coefficients to the 3rd degree
  31462. */
  31463. export class SphericalHarmonics {
  31464. /**
  31465. * Defines whether or not the harmonics have been prescaled for rendering.
  31466. */
  31467. preScaled: boolean;
  31468. /**
  31469. * The l0,0 coefficients of the spherical harmonics
  31470. */
  31471. l00: Vector3;
  31472. /**
  31473. * The l1,-1 coefficients of the spherical harmonics
  31474. */
  31475. l1_1: Vector3;
  31476. /**
  31477. * The l1,0 coefficients of the spherical harmonics
  31478. */
  31479. l10: Vector3;
  31480. /**
  31481. * The l1,1 coefficients of the spherical harmonics
  31482. */
  31483. l11: Vector3;
  31484. /**
  31485. * The l2,-2 coefficients of the spherical harmonics
  31486. */
  31487. l2_2: Vector3;
  31488. /**
  31489. * The l2,-1 coefficients of the spherical harmonics
  31490. */
  31491. l2_1: Vector3;
  31492. /**
  31493. * The l2,0 coefficients of the spherical harmonics
  31494. */
  31495. l20: Vector3;
  31496. /**
  31497. * The l2,1 coefficients of the spherical harmonics
  31498. */
  31499. l21: Vector3;
  31500. /**
  31501. * The l2,2 coefficients of the spherical harmonics
  31502. */
  31503. l22: Vector3;
  31504. /**
  31505. * Adds a light to the spherical harmonics
  31506. * @param direction the direction of the light
  31507. * @param color the color of the light
  31508. * @param deltaSolidAngle the delta solid angle of the light
  31509. */
  31510. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31511. /**
  31512. * Scales the spherical harmonics by the given amount
  31513. * @param scale the amount to scale
  31514. */
  31515. scaleInPlace(scale: number): void;
  31516. /**
  31517. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31518. *
  31519. * ```
  31520. * E_lm = A_l * L_lm
  31521. * ```
  31522. *
  31523. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31524. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31525. * the scaling factors are given in equation 9.
  31526. */
  31527. convertIncidentRadianceToIrradiance(): void;
  31528. /**
  31529. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31530. *
  31531. * ```
  31532. * L = (1/pi) * E * rho
  31533. * ```
  31534. *
  31535. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31536. */
  31537. convertIrradianceToLambertianRadiance(): void;
  31538. /**
  31539. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31540. * required operations at run time.
  31541. *
  31542. * This is simply done by scaling back the SH with Ylm constants parameter.
  31543. * The trigonometric part being applied by the shader at run time.
  31544. */
  31545. preScaleForRendering(): void;
  31546. /**
  31547. * Constructs a spherical harmonics from an array.
  31548. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31549. * @returns the spherical harmonics
  31550. */
  31551. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31552. /**
  31553. * Gets the spherical harmonics from polynomial
  31554. * @param polynomial the spherical polynomial
  31555. * @returns the spherical harmonics
  31556. */
  31557. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31558. }
  31559. /**
  31560. * Class representing spherical polynomial coefficients to the 3rd degree
  31561. */
  31562. export class SphericalPolynomial {
  31563. private _harmonics;
  31564. /**
  31565. * The spherical harmonics used to create the polynomials.
  31566. */
  31567. readonly preScaledHarmonics: SphericalHarmonics;
  31568. /**
  31569. * The x coefficients of the spherical polynomial
  31570. */
  31571. x: Vector3;
  31572. /**
  31573. * The y coefficients of the spherical polynomial
  31574. */
  31575. y: Vector3;
  31576. /**
  31577. * The z coefficients of the spherical polynomial
  31578. */
  31579. z: Vector3;
  31580. /**
  31581. * The xx coefficients of the spherical polynomial
  31582. */
  31583. xx: Vector3;
  31584. /**
  31585. * The yy coefficients of the spherical polynomial
  31586. */
  31587. yy: Vector3;
  31588. /**
  31589. * The zz coefficients of the spherical polynomial
  31590. */
  31591. zz: Vector3;
  31592. /**
  31593. * The xy coefficients of the spherical polynomial
  31594. */
  31595. xy: Vector3;
  31596. /**
  31597. * The yz coefficients of the spherical polynomial
  31598. */
  31599. yz: Vector3;
  31600. /**
  31601. * The zx coefficients of the spherical polynomial
  31602. */
  31603. zx: Vector3;
  31604. /**
  31605. * Adds an ambient color to the spherical polynomial
  31606. * @param color the color to add
  31607. */
  31608. addAmbient(color: Color3): void;
  31609. /**
  31610. * Scales the spherical polynomial by the given amount
  31611. * @param scale the amount to scale
  31612. */
  31613. scaleInPlace(scale: number): void;
  31614. /**
  31615. * Gets the spherical polynomial from harmonics
  31616. * @param harmonics the spherical harmonics
  31617. * @returns the spherical polynomial
  31618. */
  31619. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31620. /**
  31621. * Constructs a spherical polynomial from an array.
  31622. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31623. * @returns the spherical polynomial
  31624. */
  31625. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31626. }
  31627. }
  31628. declare module BABYLON {
  31629. /**
  31630. * Defines the source of the internal texture
  31631. */
  31632. export enum InternalTextureSource {
  31633. /**
  31634. * The source of the texture data is unknown
  31635. */
  31636. Unknown = 0,
  31637. /**
  31638. * Texture data comes from an URL
  31639. */
  31640. Url = 1,
  31641. /**
  31642. * Texture data is only used for temporary storage
  31643. */
  31644. Temp = 2,
  31645. /**
  31646. * Texture data comes from raw data (ArrayBuffer)
  31647. */
  31648. Raw = 3,
  31649. /**
  31650. * Texture content is dynamic (video or dynamic texture)
  31651. */
  31652. Dynamic = 4,
  31653. /**
  31654. * Texture content is generated by rendering to it
  31655. */
  31656. RenderTarget = 5,
  31657. /**
  31658. * Texture content is part of a multi render target process
  31659. */
  31660. MultiRenderTarget = 6,
  31661. /**
  31662. * Texture data comes from a cube data file
  31663. */
  31664. Cube = 7,
  31665. /**
  31666. * Texture data comes from a raw cube data
  31667. */
  31668. CubeRaw = 8,
  31669. /**
  31670. * Texture data come from a prefiltered cube data file
  31671. */
  31672. CubePrefiltered = 9,
  31673. /**
  31674. * Texture content is raw 3D data
  31675. */
  31676. Raw3D = 10,
  31677. /**
  31678. * Texture content is raw 2D array data
  31679. */
  31680. Raw2DArray = 11,
  31681. /**
  31682. * Texture content is a depth texture
  31683. */
  31684. Depth = 12,
  31685. /**
  31686. * Texture data comes from a raw cube data encoded with RGBD
  31687. */
  31688. CubeRawRGBD = 13
  31689. }
  31690. /**
  31691. * Class used to store data associated with WebGL texture data for the engine
  31692. * This class should not be used directly
  31693. */
  31694. export class InternalTexture {
  31695. /** @hidden */
  31696. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31697. /**
  31698. * Defines if the texture is ready
  31699. */
  31700. isReady: boolean;
  31701. /**
  31702. * Defines if the texture is a cube texture
  31703. */
  31704. isCube: boolean;
  31705. /**
  31706. * Defines if the texture contains 3D data
  31707. */
  31708. is3D: boolean;
  31709. /**
  31710. * Defines if the texture contains 2D array data
  31711. */
  31712. is2DArray: boolean;
  31713. /**
  31714. * Defines if the texture contains multiview data
  31715. */
  31716. isMultiview: boolean;
  31717. /**
  31718. * Gets the URL used to load this texture
  31719. */
  31720. url: string;
  31721. /**
  31722. * Gets the sampling mode of the texture
  31723. */
  31724. samplingMode: number;
  31725. /**
  31726. * Gets a boolean indicating if the texture needs mipmaps generation
  31727. */
  31728. generateMipMaps: boolean;
  31729. /**
  31730. * Gets the number of samples used by the texture (WebGL2+ only)
  31731. */
  31732. samples: number;
  31733. /**
  31734. * Gets the type of the texture (int, float...)
  31735. */
  31736. type: number;
  31737. /**
  31738. * Gets the format of the texture (RGB, RGBA...)
  31739. */
  31740. format: number;
  31741. /**
  31742. * Observable called when the texture is loaded
  31743. */
  31744. onLoadedObservable: Observable<InternalTexture>;
  31745. /**
  31746. * Gets the width of the texture
  31747. */
  31748. width: number;
  31749. /**
  31750. * Gets the height of the texture
  31751. */
  31752. height: number;
  31753. /**
  31754. * Gets the depth of the texture
  31755. */
  31756. depth: number;
  31757. /**
  31758. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31759. */
  31760. baseWidth: number;
  31761. /**
  31762. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31763. */
  31764. baseHeight: number;
  31765. /**
  31766. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31767. */
  31768. baseDepth: number;
  31769. /**
  31770. * Gets a boolean indicating if the texture is inverted on Y axis
  31771. */
  31772. invertY: boolean;
  31773. /** @hidden */
  31774. _invertVScale: boolean;
  31775. /** @hidden */
  31776. _associatedChannel: number;
  31777. /** @hidden */
  31778. _source: InternalTextureSource;
  31779. /** @hidden */
  31780. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31781. /** @hidden */
  31782. _bufferView: Nullable<ArrayBufferView>;
  31783. /** @hidden */
  31784. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31785. /** @hidden */
  31786. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31787. /** @hidden */
  31788. _size: number;
  31789. /** @hidden */
  31790. _extension: string;
  31791. /** @hidden */
  31792. _files: Nullable<string[]>;
  31793. /** @hidden */
  31794. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31795. /** @hidden */
  31796. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31797. /** @hidden */
  31798. _framebuffer: Nullable<WebGLFramebuffer>;
  31799. /** @hidden */
  31800. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31801. /** @hidden */
  31802. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31803. /** @hidden */
  31804. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31805. /** @hidden */
  31806. _attachments: Nullable<number[]>;
  31807. /** @hidden */
  31808. _cachedCoordinatesMode: Nullable<number>;
  31809. /** @hidden */
  31810. _cachedWrapU: Nullable<number>;
  31811. /** @hidden */
  31812. _cachedWrapV: Nullable<number>;
  31813. /** @hidden */
  31814. _cachedWrapR: Nullable<number>;
  31815. /** @hidden */
  31816. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31817. /** @hidden */
  31818. _isDisabled: boolean;
  31819. /** @hidden */
  31820. _compression: Nullable<string>;
  31821. /** @hidden */
  31822. _generateStencilBuffer: boolean;
  31823. /** @hidden */
  31824. _generateDepthBuffer: boolean;
  31825. /** @hidden */
  31826. _comparisonFunction: number;
  31827. /** @hidden */
  31828. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31829. /** @hidden */
  31830. _lodGenerationScale: number;
  31831. /** @hidden */
  31832. _lodGenerationOffset: number;
  31833. /** @hidden */
  31834. _colorTextureArray: Nullable<WebGLTexture>;
  31835. /** @hidden */
  31836. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31837. /** @hidden */
  31838. _lodTextureHigh: Nullable<BaseTexture>;
  31839. /** @hidden */
  31840. _lodTextureMid: Nullable<BaseTexture>;
  31841. /** @hidden */
  31842. _lodTextureLow: Nullable<BaseTexture>;
  31843. /** @hidden */
  31844. _isRGBD: boolean;
  31845. /** @hidden */
  31846. _linearSpecularLOD: boolean;
  31847. /** @hidden */
  31848. _irradianceTexture: Nullable<BaseTexture>;
  31849. /** @hidden */
  31850. _webGLTexture: Nullable<WebGLTexture>;
  31851. /** @hidden */
  31852. _references: number;
  31853. private _engine;
  31854. /**
  31855. * Gets the Engine the texture belongs to.
  31856. * @returns The babylon engine
  31857. */
  31858. getEngine(): ThinEngine;
  31859. /**
  31860. * Gets the data source type of the texture
  31861. */
  31862. readonly source: InternalTextureSource;
  31863. /**
  31864. * Creates a new InternalTexture
  31865. * @param engine defines the engine to use
  31866. * @param source defines the type of data that will be used
  31867. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31868. */
  31869. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31870. /**
  31871. * Increments the number of references (ie. the number of Texture that point to it)
  31872. */
  31873. incrementReferences(): void;
  31874. /**
  31875. * Change the size of the texture (not the size of the content)
  31876. * @param width defines the new width
  31877. * @param height defines the new height
  31878. * @param depth defines the new depth (1 by default)
  31879. */
  31880. updateSize(width: int, height: int, depth?: int): void;
  31881. /** @hidden */
  31882. _rebuild(): void;
  31883. /** @hidden */
  31884. _swapAndDie(target: InternalTexture): void;
  31885. /**
  31886. * Dispose the current allocated resources
  31887. */
  31888. dispose(): void;
  31889. }
  31890. }
  31891. declare module BABYLON {
  31892. /**
  31893. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31894. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31895. */
  31896. export class Analyser {
  31897. /**
  31898. * Gets or sets the smoothing
  31899. * @ignorenaming
  31900. */
  31901. SMOOTHING: number;
  31902. /**
  31903. * Gets or sets the FFT table size
  31904. * @ignorenaming
  31905. */
  31906. FFT_SIZE: number;
  31907. /**
  31908. * Gets or sets the bar graph amplitude
  31909. * @ignorenaming
  31910. */
  31911. BARGRAPHAMPLITUDE: number;
  31912. /**
  31913. * Gets or sets the position of the debug canvas
  31914. * @ignorenaming
  31915. */
  31916. DEBUGCANVASPOS: {
  31917. x: number;
  31918. y: number;
  31919. };
  31920. /**
  31921. * Gets or sets the debug canvas size
  31922. * @ignorenaming
  31923. */
  31924. DEBUGCANVASSIZE: {
  31925. width: number;
  31926. height: number;
  31927. };
  31928. private _byteFreqs;
  31929. private _byteTime;
  31930. private _floatFreqs;
  31931. private _webAudioAnalyser;
  31932. private _debugCanvas;
  31933. private _debugCanvasContext;
  31934. private _scene;
  31935. private _registerFunc;
  31936. private _audioEngine;
  31937. /**
  31938. * Creates a new analyser
  31939. * @param scene defines hosting scene
  31940. */
  31941. constructor(scene: Scene);
  31942. /**
  31943. * Get the number of data values you will have to play with for the visualization
  31944. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31945. * @returns a number
  31946. */
  31947. getFrequencyBinCount(): number;
  31948. /**
  31949. * Gets the current frequency data as a byte array
  31950. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31951. * @returns a Uint8Array
  31952. */
  31953. getByteFrequencyData(): Uint8Array;
  31954. /**
  31955. * Gets the current waveform as a byte array
  31956. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31957. * @returns a Uint8Array
  31958. */
  31959. getByteTimeDomainData(): Uint8Array;
  31960. /**
  31961. * Gets the current frequency data as a float array
  31962. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31963. * @returns a Float32Array
  31964. */
  31965. getFloatFrequencyData(): Float32Array;
  31966. /**
  31967. * Renders the debug canvas
  31968. */
  31969. drawDebugCanvas(): void;
  31970. /**
  31971. * Stops rendering the debug canvas and removes it
  31972. */
  31973. stopDebugCanvas(): void;
  31974. /**
  31975. * Connects two audio nodes
  31976. * @param inputAudioNode defines first node to connect
  31977. * @param outputAudioNode defines second node to connect
  31978. */
  31979. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31980. /**
  31981. * Releases all associated resources
  31982. */
  31983. dispose(): void;
  31984. }
  31985. }
  31986. declare module BABYLON {
  31987. /**
  31988. * This represents an audio engine and it is responsible
  31989. * to play, synchronize and analyse sounds throughout the application.
  31990. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31991. */
  31992. export interface IAudioEngine extends IDisposable {
  31993. /**
  31994. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31995. */
  31996. readonly canUseWebAudio: boolean;
  31997. /**
  31998. * Gets the current AudioContext if available.
  31999. */
  32000. readonly audioContext: Nullable<AudioContext>;
  32001. /**
  32002. * The master gain node defines the global audio volume of your audio engine.
  32003. */
  32004. readonly masterGain: GainNode;
  32005. /**
  32006. * Gets whether or not mp3 are supported by your browser.
  32007. */
  32008. readonly isMP3supported: boolean;
  32009. /**
  32010. * Gets whether or not ogg are supported by your browser.
  32011. */
  32012. readonly isOGGsupported: boolean;
  32013. /**
  32014. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32015. * @ignoreNaming
  32016. */
  32017. WarnedWebAudioUnsupported: boolean;
  32018. /**
  32019. * Defines if the audio engine relies on a custom unlocked button.
  32020. * In this case, the embedded button will not be displayed.
  32021. */
  32022. useCustomUnlockedButton: boolean;
  32023. /**
  32024. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32025. */
  32026. readonly unlocked: boolean;
  32027. /**
  32028. * Event raised when audio has been unlocked on the browser.
  32029. */
  32030. onAudioUnlockedObservable: Observable<AudioEngine>;
  32031. /**
  32032. * Event raised when audio has been locked on the browser.
  32033. */
  32034. onAudioLockedObservable: Observable<AudioEngine>;
  32035. /**
  32036. * Flags the audio engine in Locked state.
  32037. * This happens due to new browser policies preventing audio to autoplay.
  32038. */
  32039. lock(): void;
  32040. /**
  32041. * Unlocks the audio engine once a user action has been done on the dom.
  32042. * This is helpful to resume play once browser policies have been satisfied.
  32043. */
  32044. unlock(): void;
  32045. }
  32046. /**
  32047. * This represents the default audio engine used in babylon.
  32048. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32049. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32050. */
  32051. export class AudioEngine implements IAudioEngine {
  32052. private _audioContext;
  32053. private _audioContextInitialized;
  32054. private _muteButton;
  32055. private _hostElement;
  32056. /**
  32057. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32058. */
  32059. canUseWebAudio: boolean;
  32060. /**
  32061. * The master gain node defines the global audio volume of your audio engine.
  32062. */
  32063. masterGain: GainNode;
  32064. /**
  32065. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32066. * @ignoreNaming
  32067. */
  32068. WarnedWebAudioUnsupported: boolean;
  32069. /**
  32070. * Gets whether or not mp3 are supported by your browser.
  32071. */
  32072. isMP3supported: boolean;
  32073. /**
  32074. * Gets whether or not ogg are supported by your browser.
  32075. */
  32076. isOGGsupported: boolean;
  32077. /**
  32078. * Gets whether audio has been unlocked on the device.
  32079. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32080. * a user interaction has happened.
  32081. */
  32082. unlocked: boolean;
  32083. /**
  32084. * Defines if the audio engine relies on a custom unlocked button.
  32085. * In this case, the embedded button will not be displayed.
  32086. */
  32087. useCustomUnlockedButton: boolean;
  32088. /**
  32089. * Event raised when audio has been unlocked on the browser.
  32090. */
  32091. onAudioUnlockedObservable: Observable<AudioEngine>;
  32092. /**
  32093. * Event raised when audio has been locked on the browser.
  32094. */
  32095. onAudioLockedObservable: Observable<AudioEngine>;
  32096. /**
  32097. * Gets the current AudioContext if available.
  32098. */
  32099. readonly audioContext: Nullable<AudioContext>;
  32100. private _connectedAnalyser;
  32101. /**
  32102. * Instantiates a new audio engine.
  32103. *
  32104. * There should be only one per page as some browsers restrict the number
  32105. * of audio contexts you can create.
  32106. * @param hostElement defines the host element where to display the mute icon if necessary
  32107. */
  32108. constructor(hostElement?: Nullable<HTMLElement>);
  32109. /**
  32110. * Flags the audio engine in Locked state.
  32111. * This happens due to new browser policies preventing audio to autoplay.
  32112. */
  32113. lock(): void;
  32114. /**
  32115. * Unlocks the audio engine once a user action has been done on the dom.
  32116. * This is helpful to resume play once browser policies have been satisfied.
  32117. */
  32118. unlock(): void;
  32119. private _resumeAudioContext;
  32120. private _initializeAudioContext;
  32121. private _tryToRun;
  32122. private _triggerRunningState;
  32123. private _triggerSuspendedState;
  32124. private _displayMuteButton;
  32125. private _moveButtonToTopLeft;
  32126. private _onResize;
  32127. private _hideMuteButton;
  32128. /**
  32129. * Destroy and release the resources associated with the audio ccontext.
  32130. */
  32131. dispose(): void;
  32132. /**
  32133. * Gets the global volume sets on the master gain.
  32134. * @returns the global volume if set or -1 otherwise
  32135. */
  32136. getGlobalVolume(): number;
  32137. /**
  32138. * Sets the global volume of your experience (sets on the master gain).
  32139. * @param newVolume Defines the new global volume of the application
  32140. */
  32141. setGlobalVolume(newVolume: number): void;
  32142. /**
  32143. * Connect the audio engine to an audio analyser allowing some amazing
  32144. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32145. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32146. * @param analyser The analyser to connect to the engine
  32147. */
  32148. connectToAnalyser(analyser: Analyser): void;
  32149. }
  32150. }
  32151. declare module BABYLON {
  32152. /**
  32153. * Interface used to present a loading screen while loading a scene
  32154. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32155. */
  32156. export interface ILoadingScreen {
  32157. /**
  32158. * Function called to display the loading screen
  32159. */
  32160. displayLoadingUI: () => void;
  32161. /**
  32162. * Function called to hide the loading screen
  32163. */
  32164. hideLoadingUI: () => void;
  32165. /**
  32166. * Gets or sets the color to use for the background
  32167. */
  32168. loadingUIBackgroundColor: string;
  32169. /**
  32170. * Gets or sets the text to display while loading
  32171. */
  32172. loadingUIText: string;
  32173. }
  32174. /**
  32175. * Class used for the default loading screen
  32176. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32177. */
  32178. export class DefaultLoadingScreen implements ILoadingScreen {
  32179. private _renderingCanvas;
  32180. private _loadingText;
  32181. private _loadingDivBackgroundColor;
  32182. private _loadingDiv;
  32183. private _loadingTextDiv;
  32184. /** Gets or sets the logo url to use for the default loading screen */
  32185. static DefaultLogoUrl: string;
  32186. /** Gets or sets the spinner url to use for the default loading screen */
  32187. static DefaultSpinnerUrl: string;
  32188. /**
  32189. * Creates a new default loading screen
  32190. * @param _renderingCanvas defines the canvas used to render the scene
  32191. * @param _loadingText defines the default text to display
  32192. * @param _loadingDivBackgroundColor defines the default background color
  32193. */
  32194. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32195. /**
  32196. * Function called to display the loading screen
  32197. */
  32198. displayLoadingUI(): void;
  32199. /**
  32200. * Function called to hide the loading screen
  32201. */
  32202. hideLoadingUI(): void;
  32203. /**
  32204. * Gets or sets the text to display while loading
  32205. */
  32206. loadingUIText: string;
  32207. /**
  32208. * Gets or sets the color to use for the background
  32209. */
  32210. loadingUIBackgroundColor: string;
  32211. private _resizeLoadingUI;
  32212. }
  32213. }
  32214. declare module BABYLON {
  32215. /**
  32216. * Interface for any object that can request an animation frame
  32217. */
  32218. export interface ICustomAnimationFrameRequester {
  32219. /**
  32220. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32221. */
  32222. renderFunction?: Function;
  32223. /**
  32224. * Called to request the next frame to render to
  32225. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32226. */
  32227. requestAnimationFrame: Function;
  32228. /**
  32229. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32230. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32231. */
  32232. requestID?: number;
  32233. }
  32234. }
  32235. declare module BABYLON {
  32236. /**
  32237. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32238. */
  32239. export class PerformanceMonitor {
  32240. private _enabled;
  32241. private _rollingFrameTime;
  32242. private _lastFrameTimeMs;
  32243. /**
  32244. * constructor
  32245. * @param frameSampleSize The number of samples required to saturate the sliding window
  32246. */
  32247. constructor(frameSampleSize?: number);
  32248. /**
  32249. * Samples current frame
  32250. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32251. */
  32252. sampleFrame(timeMs?: number): void;
  32253. /**
  32254. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32255. */
  32256. readonly averageFrameTime: number;
  32257. /**
  32258. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32259. */
  32260. readonly averageFrameTimeVariance: number;
  32261. /**
  32262. * Returns the frame time of the most recent frame
  32263. */
  32264. readonly instantaneousFrameTime: number;
  32265. /**
  32266. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32267. */
  32268. readonly averageFPS: number;
  32269. /**
  32270. * Returns the average framerate in frames per second using the most recent frame time
  32271. */
  32272. readonly instantaneousFPS: number;
  32273. /**
  32274. * Returns true if enough samples have been taken to completely fill the sliding window
  32275. */
  32276. readonly isSaturated: boolean;
  32277. /**
  32278. * Enables contributions to the sliding window sample set
  32279. */
  32280. enable(): void;
  32281. /**
  32282. * Disables contributions to the sliding window sample set
  32283. * Samples will not be interpolated over the disabled period
  32284. */
  32285. disable(): void;
  32286. /**
  32287. * Returns true if sampling is enabled
  32288. */
  32289. readonly isEnabled: boolean;
  32290. /**
  32291. * Resets performance monitor
  32292. */
  32293. reset(): void;
  32294. }
  32295. /**
  32296. * RollingAverage
  32297. *
  32298. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32299. */
  32300. export class RollingAverage {
  32301. /**
  32302. * Current average
  32303. */
  32304. average: number;
  32305. /**
  32306. * Current variance
  32307. */
  32308. variance: number;
  32309. protected _samples: Array<number>;
  32310. protected _sampleCount: number;
  32311. protected _pos: number;
  32312. protected _m2: number;
  32313. /**
  32314. * constructor
  32315. * @param length The number of samples required to saturate the sliding window
  32316. */
  32317. constructor(length: number);
  32318. /**
  32319. * Adds a sample to the sample set
  32320. * @param v The sample value
  32321. */
  32322. add(v: number): void;
  32323. /**
  32324. * Returns previously added values or null if outside of history or outside the sliding window domain
  32325. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32326. * @return Value previously recorded with add() or null if outside of range
  32327. */
  32328. history(i: number): number;
  32329. /**
  32330. * Returns true if enough samples have been taken to completely fill the sliding window
  32331. * @return true if sample-set saturated
  32332. */
  32333. isSaturated(): boolean;
  32334. /**
  32335. * Resets the rolling average (equivalent to 0 samples taken so far)
  32336. */
  32337. reset(): void;
  32338. /**
  32339. * Wraps a value around the sample range boundaries
  32340. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32341. * @return Wrapped position in sample range
  32342. */
  32343. protected _wrapPosition(i: number): number;
  32344. }
  32345. }
  32346. declare module BABYLON {
  32347. /**
  32348. * This class is used to track a performance counter which is number based.
  32349. * The user has access to many properties which give statistics of different nature.
  32350. *
  32351. * The implementer can track two kinds of Performance Counter: time and count.
  32352. * 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.
  32353. * 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.
  32354. */
  32355. export class PerfCounter {
  32356. /**
  32357. * Gets or sets a global boolean to turn on and off all the counters
  32358. */
  32359. static Enabled: boolean;
  32360. /**
  32361. * Returns the smallest value ever
  32362. */
  32363. readonly min: number;
  32364. /**
  32365. * Returns the biggest value ever
  32366. */
  32367. readonly max: number;
  32368. /**
  32369. * Returns the average value since the performance counter is running
  32370. */
  32371. readonly average: number;
  32372. /**
  32373. * Returns the average value of the last second the counter was monitored
  32374. */
  32375. readonly lastSecAverage: number;
  32376. /**
  32377. * Returns the current value
  32378. */
  32379. readonly current: number;
  32380. /**
  32381. * Gets the accumulated total
  32382. */
  32383. readonly total: number;
  32384. /**
  32385. * Gets the total value count
  32386. */
  32387. readonly count: number;
  32388. /**
  32389. * Creates a new counter
  32390. */
  32391. constructor();
  32392. /**
  32393. * Call this method to start monitoring a new frame.
  32394. * 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.
  32395. */
  32396. fetchNewFrame(): void;
  32397. /**
  32398. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32399. * @param newCount the count value to add to the monitored count
  32400. * @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.
  32401. */
  32402. addCount(newCount: number, fetchResult: boolean): void;
  32403. /**
  32404. * Start monitoring this performance counter
  32405. */
  32406. beginMonitoring(): void;
  32407. /**
  32408. * Compute the time lapsed since the previous beginMonitoring() call.
  32409. * @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
  32410. */
  32411. endMonitoring(newFrame?: boolean): void;
  32412. private _fetchResult;
  32413. private _startMonitoringTime;
  32414. private _min;
  32415. private _max;
  32416. private _average;
  32417. private _current;
  32418. private _totalValueCount;
  32419. private _totalAccumulated;
  32420. private _lastSecAverage;
  32421. private _lastSecAccumulated;
  32422. private _lastSecTime;
  32423. private _lastSecValueCount;
  32424. }
  32425. }
  32426. declare module BABYLON {
  32427. interface ThinEngine {
  32428. /**
  32429. * Sets alpha constants used by some alpha blending modes
  32430. * @param r defines the red component
  32431. * @param g defines the green component
  32432. * @param b defines the blue component
  32433. * @param a defines the alpha component
  32434. */
  32435. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32436. /**
  32437. * Sets the current alpha mode
  32438. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32439. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32440. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32441. */
  32442. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32443. /**
  32444. * Gets the current alpha mode
  32445. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32446. * @returns the current alpha mode
  32447. */
  32448. getAlphaMode(): number;
  32449. /**
  32450. * Sets the current alpha equation
  32451. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32452. */
  32453. setAlphaEquation(equation: number): void;
  32454. /**
  32455. * Gets the current alpha equation.
  32456. * @returns the current alpha equation
  32457. */
  32458. getAlphaEquation(): number;
  32459. }
  32460. }
  32461. declare module BABYLON {
  32462. /**
  32463. * Defines the interface used by display changed events
  32464. */
  32465. export interface IDisplayChangedEventArgs {
  32466. /** Gets the vrDisplay object (if any) */
  32467. vrDisplay: Nullable<any>;
  32468. /** Gets a boolean indicating if webVR is supported */
  32469. vrSupported: boolean;
  32470. }
  32471. /**
  32472. * Defines the interface used by objects containing a viewport (like a camera)
  32473. */
  32474. interface IViewportOwnerLike {
  32475. /**
  32476. * Gets or sets the viewport
  32477. */
  32478. viewport: IViewportLike;
  32479. }
  32480. /**
  32481. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32482. */
  32483. export class Engine extends ThinEngine {
  32484. /** Defines that alpha blending is disabled */
  32485. static readonly ALPHA_DISABLE: number;
  32486. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32487. static readonly ALPHA_ADD: number;
  32488. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32489. static readonly ALPHA_COMBINE: number;
  32490. /** Defines that alpha blending to DEST - SRC * DEST */
  32491. static readonly ALPHA_SUBTRACT: number;
  32492. /** Defines that alpha blending to SRC * DEST */
  32493. static readonly ALPHA_MULTIPLY: number;
  32494. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32495. static readonly ALPHA_MAXIMIZED: number;
  32496. /** Defines that alpha blending to SRC + DEST */
  32497. static readonly ALPHA_ONEONE: number;
  32498. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32499. static readonly ALPHA_PREMULTIPLIED: number;
  32500. /**
  32501. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32502. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32503. */
  32504. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32505. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32506. static readonly ALPHA_INTERPOLATE: number;
  32507. /**
  32508. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32509. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32510. */
  32511. static readonly ALPHA_SCREENMODE: number;
  32512. /** Defines that the ressource is not delayed*/
  32513. static readonly DELAYLOADSTATE_NONE: number;
  32514. /** Defines that the ressource was successfully delay loaded */
  32515. static readonly DELAYLOADSTATE_LOADED: number;
  32516. /** Defines that the ressource is currently delay loading */
  32517. static readonly DELAYLOADSTATE_LOADING: number;
  32518. /** Defines that the ressource is delayed and has not started loading */
  32519. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32520. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32521. static readonly NEVER: number;
  32522. /** 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 */
  32523. static readonly ALWAYS: number;
  32524. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32525. static readonly LESS: number;
  32526. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32527. static readonly EQUAL: number;
  32528. /** 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 */
  32529. static readonly LEQUAL: number;
  32530. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32531. static readonly GREATER: number;
  32532. /** 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 */
  32533. static readonly GEQUAL: number;
  32534. /** 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 */
  32535. static readonly NOTEQUAL: number;
  32536. /** Passed to stencilOperation to specify that stencil value must be kept */
  32537. static readonly KEEP: number;
  32538. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32539. static readonly REPLACE: number;
  32540. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32541. static readonly INCR: number;
  32542. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32543. static readonly DECR: number;
  32544. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32545. static readonly INVERT: number;
  32546. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32547. static readonly INCR_WRAP: number;
  32548. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32549. static readonly DECR_WRAP: number;
  32550. /** Texture is not repeating outside of 0..1 UVs */
  32551. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32552. /** Texture is repeating outside of 0..1 UVs */
  32553. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32554. /** Texture is repeating and mirrored */
  32555. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32556. /** ALPHA */
  32557. static readonly TEXTUREFORMAT_ALPHA: number;
  32558. /** LUMINANCE */
  32559. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32560. /** LUMINANCE_ALPHA */
  32561. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32562. /** RGB */
  32563. static readonly TEXTUREFORMAT_RGB: number;
  32564. /** RGBA */
  32565. static readonly TEXTUREFORMAT_RGBA: number;
  32566. /** RED */
  32567. static readonly TEXTUREFORMAT_RED: number;
  32568. /** RED (2nd reference) */
  32569. static readonly TEXTUREFORMAT_R: number;
  32570. /** RG */
  32571. static readonly TEXTUREFORMAT_RG: number;
  32572. /** RED_INTEGER */
  32573. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32574. /** RED_INTEGER (2nd reference) */
  32575. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32576. /** RG_INTEGER */
  32577. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32578. /** RGB_INTEGER */
  32579. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32580. /** RGBA_INTEGER */
  32581. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32582. /** UNSIGNED_BYTE */
  32583. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32584. /** UNSIGNED_BYTE (2nd reference) */
  32585. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32586. /** FLOAT */
  32587. static readonly TEXTURETYPE_FLOAT: number;
  32588. /** HALF_FLOAT */
  32589. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32590. /** BYTE */
  32591. static readonly TEXTURETYPE_BYTE: number;
  32592. /** SHORT */
  32593. static readonly TEXTURETYPE_SHORT: number;
  32594. /** UNSIGNED_SHORT */
  32595. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32596. /** INT */
  32597. static readonly TEXTURETYPE_INT: number;
  32598. /** UNSIGNED_INT */
  32599. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32600. /** UNSIGNED_SHORT_4_4_4_4 */
  32601. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32602. /** UNSIGNED_SHORT_5_5_5_1 */
  32603. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32604. /** UNSIGNED_SHORT_5_6_5 */
  32605. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32606. /** UNSIGNED_INT_2_10_10_10_REV */
  32607. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32608. /** UNSIGNED_INT_24_8 */
  32609. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32610. /** UNSIGNED_INT_10F_11F_11F_REV */
  32611. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32612. /** UNSIGNED_INT_5_9_9_9_REV */
  32613. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32614. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32615. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32616. /** nearest is mag = nearest and min = nearest and mip = linear */
  32617. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32618. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32619. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32620. /** Trilinear is mag = linear and min = linear and mip = linear */
  32621. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32622. /** nearest is mag = nearest and min = nearest and mip = linear */
  32623. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32624. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32625. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32626. /** Trilinear is mag = linear and min = linear and mip = linear */
  32627. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32628. /** mag = nearest and min = nearest and mip = nearest */
  32629. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32630. /** mag = nearest and min = linear and mip = nearest */
  32631. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32632. /** mag = nearest and min = linear and mip = linear */
  32633. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32634. /** mag = nearest and min = linear and mip = none */
  32635. static readonly TEXTURE_NEAREST_LINEAR: number;
  32636. /** mag = nearest and min = nearest and mip = none */
  32637. static readonly TEXTURE_NEAREST_NEAREST: number;
  32638. /** mag = linear and min = nearest and mip = nearest */
  32639. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32640. /** mag = linear and min = nearest and mip = linear */
  32641. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32642. /** mag = linear and min = linear and mip = none */
  32643. static readonly TEXTURE_LINEAR_LINEAR: number;
  32644. /** mag = linear and min = nearest and mip = none */
  32645. static readonly TEXTURE_LINEAR_NEAREST: number;
  32646. /** Explicit coordinates mode */
  32647. static readonly TEXTURE_EXPLICIT_MODE: number;
  32648. /** Spherical coordinates mode */
  32649. static readonly TEXTURE_SPHERICAL_MODE: number;
  32650. /** Planar coordinates mode */
  32651. static readonly TEXTURE_PLANAR_MODE: number;
  32652. /** Cubic coordinates mode */
  32653. static readonly TEXTURE_CUBIC_MODE: number;
  32654. /** Projection coordinates mode */
  32655. static readonly TEXTURE_PROJECTION_MODE: number;
  32656. /** Skybox coordinates mode */
  32657. static readonly TEXTURE_SKYBOX_MODE: number;
  32658. /** Inverse Cubic coordinates mode */
  32659. static readonly TEXTURE_INVCUBIC_MODE: number;
  32660. /** Equirectangular coordinates mode */
  32661. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32662. /** Equirectangular Fixed coordinates mode */
  32663. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32664. /** Equirectangular Fixed Mirrored coordinates mode */
  32665. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32666. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32667. static readonly SCALEMODE_FLOOR: number;
  32668. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32669. static readonly SCALEMODE_NEAREST: number;
  32670. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32671. static readonly SCALEMODE_CEILING: number;
  32672. /**
  32673. * Returns the current npm package of the sdk
  32674. */
  32675. static readonly NpmPackage: string;
  32676. /**
  32677. * Returns the current version of the framework
  32678. */
  32679. static readonly Version: string;
  32680. /** Gets the list of created engines */
  32681. static readonly Instances: Engine[];
  32682. /**
  32683. * Gets the latest created engine
  32684. */
  32685. static readonly LastCreatedEngine: Nullable<Engine>;
  32686. /**
  32687. * Gets the latest created scene
  32688. */
  32689. static readonly LastCreatedScene: Nullable<Scene>;
  32690. /**
  32691. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32692. * @param flag defines which part of the materials must be marked as dirty
  32693. * @param predicate defines a predicate used to filter which materials should be affected
  32694. */
  32695. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32696. /**
  32697. * Method called to create the default loading screen.
  32698. * This can be overriden in your own app.
  32699. * @param canvas The rendering canvas element
  32700. * @returns The loading screen
  32701. */
  32702. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32703. /**
  32704. * Method called to create the default rescale post process on each engine.
  32705. */
  32706. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32707. /**
  32708. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32709. **/
  32710. enableOfflineSupport: boolean;
  32711. /**
  32712. * 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)
  32713. **/
  32714. disableManifestCheck: boolean;
  32715. /**
  32716. * Gets the list of created scenes
  32717. */
  32718. scenes: Scene[];
  32719. /**
  32720. * Event raised when a new scene is created
  32721. */
  32722. onNewSceneAddedObservable: Observable<Scene>;
  32723. /**
  32724. * Gets the list of created postprocesses
  32725. */
  32726. postProcesses: PostProcess[];
  32727. /**
  32728. * Gets a boolean indicating if the pointer is currently locked
  32729. */
  32730. isPointerLock: boolean;
  32731. /**
  32732. * Observable event triggered each time the rendering canvas is resized
  32733. */
  32734. onResizeObservable: Observable<Engine>;
  32735. /**
  32736. * Observable event triggered each time the canvas loses focus
  32737. */
  32738. onCanvasBlurObservable: Observable<Engine>;
  32739. /**
  32740. * Observable event triggered each time the canvas gains focus
  32741. */
  32742. onCanvasFocusObservable: Observable<Engine>;
  32743. /**
  32744. * Observable event triggered each time the canvas receives pointerout event
  32745. */
  32746. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32747. /**
  32748. * Observable raised when the engine begins a new frame
  32749. */
  32750. onBeginFrameObservable: Observable<Engine>;
  32751. /**
  32752. * If set, will be used to request the next animation frame for the render loop
  32753. */
  32754. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32755. /**
  32756. * Observable raised when the engine ends the current frame
  32757. */
  32758. onEndFrameObservable: Observable<Engine>;
  32759. /**
  32760. * Observable raised when the engine is about to compile a shader
  32761. */
  32762. onBeforeShaderCompilationObservable: Observable<Engine>;
  32763. /**
  32764. * Observable raised when the engine has jsut compiled a shader
  32765. */
  32766. onAfterShaderCompilationObservable: Observable<Engine>;
  32767. /**
  32768. * Gets the audio engine
  32769. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32770. * @ignorenaming
  32771. */
  32772. static audioEngine: IAudioEngine;
  32773. /**
  32774. * Default AudioEngine factory responsible of creating the Audio Engine.
  32775. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32776. */
  32777. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32778. /**
  32779. * Default offline support factory responsible of creating a tool used to store data locally.
  32780. * By default, this will create a Database object if the workload has been embedded.
  32781. */
  32782. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32783. private _loadingScreen;
  32784. private _pointerLockRequested;
  32785. private _dummyFramebuffer;
  32786. private _rescalePostProcess;
  32787. private _deterministicLockstep;
  32788. private _lockstepMaxSteps;
  32789. private _timeStep;
  32790. protected readonly _supportsHardwareTextureRescaling: boolean;
  32791. private _fps;
  32792. private _deltaTime;
  32793. /** @hidden */
  32794. _drawCalls: PerfCounter;
  32795. /**
  32796. * Turn this value on if you want to pause FPS computation when in background
  32797. */
  32798. disablePerformanceMonitorInBackground: boolean;
  32799. private _performanceMonitor;
  32800. /**
  32801. * Gets the performance monitor attached to this engine
  32802. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32803. */
  32804. readonly performanceMonitor: PerformanceMonitor;
  32805. private _onFocus;
  32806. private _onBlur;
  32807. private _onCanvasPointerOut;
  32808. private _onCanvasBlur;
  32809. private _onCanvasFocus;
  32810. private _onFullscreenChange;
  32811. private _onPointerLockChange;
  32812. /**
  32813. * Gets the HTML element used to attach event listeners
  32814. * @returns a HTML element
  32815. */
  32816. getInputElement(): Nullable<HTMLElement>;
  32817. /**
  32818. * Creates a new engine
  32819. * @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
  32820. * @param antialias defines enable antialiasing (default: false)
  32821. * @param options defines further options to be sent to the getContext() function
  32822. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32823. */
  32824. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32825. /**
  32826. * Gets current aspect ratio
  32827. * @param viewportOwner defines the camera to use to get the aspect ratio
  32828. * @param useScreen defines if screen size must be used (or the current render target if any)
  32829. * @returns a number defining the aspect ratio
  32830. */
  32831. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32832. /**
  32833. * Gets current screen aspect ratio
  32834. * @returns a number defining the aspect ratio
  32835. */
  32836. getScreenAspectRatio(): number;
  32837. /**
  32838. * Gets the client rect of the HTML canvas attached with the current webGL context
  32839. * @returns a client rectanglee
  32840. */
  32841. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32842. /**
  32843. * Gets the client rect of the HTML element used for events
  32844. * @returns a client rectanglee
  32845. */
  32846. getInputElementClientRect(): Nullable<ClientRect>;
  32847. /**
  32848. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32849. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32850. * @returns true if engine is in deterministic lock step mode
  32851. */
  32852. isDeterministicLockStep(): boolean;
  32853. /**
  32854. * Gets the max steps when engine is running in deterministic lock step
  32855. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32856. * @returns the max steps
  32857. */
  32858. getLockstepMaxSteps(): number;
  32859. /**
  32860. * Returns the time in ms between steps when using deterministic lock step.
  32861. * @returns time step in (ms)
  32862. */
  32863. getTimeStep(): number;
  32864. /**
  32865. * Force the mipmap generation for the given render target texture
  32866. * @param texture defines the render target texture to use
  32867. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  32868. */
  32869. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  32870. /** States */
  32871. /**
  32872. * Set various states to the webGL context
  32873. * @param culling defines backface culling state
  32874. * @param zOffset defines the value to apply to zOffset (0 by default)
  32875. * @param force defines if states must be applied even if cache is up to date
  32876. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32877. */
  32878. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32879. /**
  32880. * Set the z offset to apply to current rendering
  32881. * @param value defines the offset to apply
  32882. */
  32883. setZOffset(value: number): void;
  32884. /**
  32885. * Gets the current value of the zOffset
  32886. * @returns the current zOffset state
  32887. */
  32888. getZOffset(): number;
  32889. /**
  32890. * Enable or disable depth buffering
  32891. * @param enable defines the state to set
  32892. */
  32893. setDepthBuffer(enable: boolean): void;
  32894. /**
  32895. * Gets a boolean indicating if depth writing is enabled
  32896. * @returns the current depth writing state
  32897. */
  32898. getDepthWrite(): boolean;
  32899. /**
  32900. * Enable or disable depth writing
  32901. * @param enable defines the state to set
  32902. */
  32903. setDepthWrite(enable: boolean): void;
  32904. /**
  32905. * Gets a boolean indicating if stencil buffer is enabled
  32906. * @returns the current stencil buffer state
  32907. */
  32908. getStencilBuffer(): boolean;
  32909. /**
  32910. * Enable or disable the stencil buffer
  32911. * @param enable defines if the stencil buffer must be enabled or disabled
  32912. */
  32913. setStencilBuffer(enable: boolean): void;
  32914. /**
  32915. * Gets the current stencil mask
  32916. * @returns a number defining the new stencil mask to use
  32917. */
  32918. getStencilMask(): number;
  32919. /**
  32920. * Sets the current stencil mask
  32921. * @param mask defines the new stencil mask to use
  32922. */
  32923. setStencilMask(mask: number): void;
  32924. /**
  32925. * Gets the current stencil function
  32926. * @returns a number defining the stencil function to use
  32927. */
  32928. getStencilFunction(): number;
  32929. /**
  32930. * Gets the current stencil reference value
  32931. * @returns a number defining the stencil reference value to use
  32932. */
  32933. getStencilFunctionReference(): number;
  32934. /**
  32935. * Gets the current stencil mask
  32936. * @returns a number defining the stencil mask to use
  32937. */
  32938. getStencilFunctionMask(): number;
  32939. /**
  32940. * Sets the current stencil function
  32941. * @param stencilFunc defines the new stencil function to use
  32942. */
  32943. setStencilFunction(stencilFunc: number): void;
  32944. /**
  32945. * Sets the current stencil reference
  32946. * @param reference defines the new stencil reference to use
  32947. */
  32948. setStencilFunctionReference(reference: number): void;
  32949. /**
  32950. * Sets the current stencil mask
  32951. * @param mask defines the new stencil mask to use
  32952. */
  32953. setStencilFunctionMask(mask: number): void;
  32954. /**
  32955. * Gets the current stencil operation when stencil fails
  32956. * @returns a number defining stencil operation to use when stencil fails
  32957. */
  32958. getStencilOperationFail(): number;
  32959. /**
  32960. * Gets the current stencil operation when depth fails
  32961. * @returns a number defining stencil operation to use when depth fails
  32962. */
  32963. getStencilOperationDepthFail(): number;
  32964. /**
  32965. * Gets the current stencil operation when stencil passes
  32966. * @returns a number defining stencil operation to use when stencil passes
  32967. */
  32968. getStencilOperationPass(): number;
  32969. /**
  32970. * Sets the stencil operation to use when stencil fails
  32971. * @param operation defines the stencil operation to use when stencil fails
  32972. */
  32973. setStencilOperationFail(operation: number): void;
  32974. /**
  32975. * Sets the stencil operation to use when depth fails
  32976. * @param operation defines the stencil operation to use when depth fails
  32977. */
  32978. setStencilOperationDepthFail(operation: number): void;
  32979. /**
  32980. * Sets the stencil operation to use when stencil passes
  32981. * @param operation defines the stencil operation to use when stencil passes
  32982. */
  32983. setStencilOperationPass(operation: number): void;
  32984. /**
  32985. * Sets a boolean indicating if the dithering state is enabled or disabled
  32986. * @param value defines the dithering state
  32987. */
  32988. setDitheringState(value: boolean): void;
  32989. /**
  32990. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32991. * @param value defines the rasterizer state
  32992. */
  32993. setRasterizerState(value: boolean): void;
  32994. /**
  32995. * Gets the current depth function
  32996. * @returns a number defining the depth function
  32997. */
  32998. getDepthFunction(): Nullable<number>;
  32999. /**
  33000. * Sets the current depth function
  33001. * @param depthFunc defines the function to use
  33002. */
  33003. setDepthFunction(depthFunc: number): void;
  33004. /**
  33005. * Sets the current depth function to GREATER
  33006. */
  33007. setDepthFunctionToGreater(): void;
  33008. /**
  33009. * Sets the current depth function to GEQUAL
  33010. */
  33011. setDepthFunctionToGreaterOrEqual(): void;
  33012. /**
  33013. * Sets the current depth function to LESS
  33014. */
  33015. setDepthFunctionToLess(): void;
  33016. /**
  33017. * Sets the current depth function to LEQUAL
  33018. */
  33019. setDepthFunctionToLessOrEqual(): void;
  33020. private _cachedStencilBuffer;
  33021. private _cachedStencilFunction;
  33022. private _cachedStencilMask;
  33023. private _cachedStencilOperationPass;
  33024. private _cachedStencilOperationFail;
  33025. private _cachedStencilOperationDepthFail;
  33026. private _cachedStencilReference;
  33027. /**
  33028. * Caches the the state of the stencil buffer
  33029. */
  33030. cacheStencilState(): void;
  33031. /**
  33032. * Restores the state of the stencil buffer
  33033. */
  33034. restoreStencilState(): void;
  33035. /**
  33036. * Directly set the WebGL Viewport
  33037. * @param x defines the x coordinate of the viewport (in screen space)
  33038. * @param y defines the y coordinate of the viewport (in screen space)
  33039. * @param width defines the width of the viewport (in screen space)
  33040. * @param height defines the height of the viewport (in screen space)
  33041. * @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
  33042. */
  33043. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33044. /**
  33045. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33046. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33047. * @param y defines the y-coordinate of the corner of the clear rectangle
  33048. * @param width defines the width of the clear rectangle
  33049. * @param height defines the height of the clear rectangle
  33050. * @param clearColor defines the clear color
  33051. */
  33052. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33053. /**
  33054. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33055. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33056. * @param y defines the y-coordinate of the corner of the clear rectangle
  33057. * @param width defines the width of the clear rectangle
  33058. * @param height defines the height of the clear rectangle
  33059. */
  33060. enableScissor(x: number, y: number, width: number, height: number): void;
  33061. /**
  33062. * Disable previously set scissor test rectangle
  33063. */
  33064. disableScissor(): void;
  33065. protected _reportDrawCall(): void;
  33066. /**
  33067. * Initializes a webVR display and starts listening to display change events
  33068. * The onVRDisplayChangedObservable will be notified upon these changes
  33069. * @returns The onVRDisplayChangedObservable
  33070. */
  33071. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33072. /** @hidden */
  33073. _prepareVRComponent(): void;
  33074. /** @hidden */
  33075. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33076. /** @hidden */
  33077. _submitVRFrame(): void;
  33078. /**
  33079. * Call this function to leave webVR mode
  33080. * Will do nothing if webVR is not supported or if there is no webVR device
  33081. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33082. */
  33083. disableVR(): void;
  33084. /**
  33085. * Gets a boolean indicating that the system is in VR mode and is presenting
  33086. * @returns true if VR mode is engaged
  33087. */
  33088. isVRPresenting(): boolean;
  33089. /** @hidden */
  33090. _requestVRFrame(): void;
  33091. /** @hidden */
  33092. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33093. /**
  33094. * Gets the source code of the vertex shader associated with a specific webGL program
  33095. * @param program defines the program to use
  33096. * @returns a string containing the source code of the vertex shader associated with the program
  33097. */
  33098. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33099. /**
  33100. * Gets the source code of the fragment shader associated with a specific webGL program
  33101. * @param program defines the program to use
  33102. * @returns a string containing the source code of the fragment shader associated with the program
  33103. */
  33104. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33105. /**
  33106. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33107. * @param x defines the x coordinate of the rectangle where pixels must be read
  33108. * @param y defines the y coordinate of the rectangle where pixels must be read
  33109. * @param width defines the width of the rectangle where pixels must be read
  33110. * @param height defines the height of the rectangle where pixels must be read
  33111. * @returns a Uint8Array containing RGBA colors
  33112. */
  33113. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  33114. /**
  33115. * Sets a depth stencil texture from a render target to the according uniform.
  33116. * @param channel The texture channel
  33117. * @param uniform The uniform to set
  33118. * @param texture The render target texture containing the depth stencil texture to apply
  33119. */
  33120. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33121. /**
  33122. * Sets a texture to the webGL context from a postprocess
  33123. * @param channel defines the channel to use
  33124. * @param postProcess defines the source postprocess
  33125. */
  33126. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33127. /**
  33128. * Binds the output of the passed in post process to the texture channel specified
  33129. * @param channel The channel the texture should be bound to
  33130. * @param postProcess The post process which's output should be bound
  33131. */
  33132. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33133. /** @hidden */
  33134. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33135. protected _rebuildBuffers(): void;
  33136. /** @hidden */
  33137. _renderFrame(): void;
  33138. _renderLoop(): void;
  33139. /** @hidden */
  33140. _renderViews(): boolean;
  33141. /**
  33142. * Toggle full screen mode
  33143. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33144. */
  33145. switchFullscreen(requestPointerLock: boolean): void;
  33146. /**
  33147. * Enters full screen mode
  33148. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33149. */
  33150. enterFullscreen(requestPointerLock: boolean): void;
  33151. /**
  33152. * Exits full screen mode
  33153. */
  33154. exitFullscreen(): void;
  33155. /**
  33156. * Enters Pointerlock mode
  33157. */
  33158. enterPointerlock(): void;
  33159. /**
  33160. * Exits Pointerlock mode
  33161. */
  33162. exitPointerlock(): void;
  33163. /**
  33164. * Begin a new frame
  33165. */
  33166. beginFrame(): void;
  33167. /**
  33168. * Enf the current frame
  33169. */
  33170. endFrame(): void;
  33171. resize(): void;
  33172. /**
  33173. * Set the compressed texture format to use, based on the formats you have, and the formats
  33174. * supported by the hardware / browser.
  33175. *
  33176. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33177. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33178. * to API arguments needed to compressed textures. This puts the burden on the container
  33179. * generator to house the arcane code for determining these for current & future formats.
  33180. *
  33181. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33182. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33183. *
  33184. * Note: The result of this call is not taken into account when a texture is base64.
  33185. *
  33186. * @param formatsAvailable defines the list of those format families you have created
  33187. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33188. *
  33189. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33190. * @returns The extension selected.
  33191. */
  33192. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33193. /**
  33194. * Set the compressed texture extensions or file names to skip.
  33195. *
  33196. * @param skippedFiles defines the list of those texture files you want to skip
  33197. * Example: [".dds", ".env", "myfile.png"]
  33198. */
  33199. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  33200. /**
  33201. * Force a specific size of the canvas
  33202. * @param width defines the new canvas' width
  33203. * @param height defines the new canvas' height
  33204. */
  33205. setSize(width: number, height: number): void;
  33206. /**
  33207. * Updates a dynamic vertex buffer.
  33208. * @param vertexBuffer the vertex buffer to update
  33209. * @param data the data used to update the vertex buffer
  33210. * @param byteOffset the byte offset of the data
  33211. * @param byteLength the byte length of the data
  33212. */
  33213. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33214. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33215. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33216. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33217. _releaseTexture(texture: InternalTexture): void;
  33218. /**
  33219. * @hidden
  33220. * Rescales a texture
  33221. * @param source input texutre
  33222. * @param destination destination texture
  33223. * @param scene scene to use to render the resize
  33224. * @param internalFormat format to use when resizing
  33225. * @param onComplete callback to be called when resize has completed
  33226. */
  33227. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33228. /**
  33229. * Gets the current framerate
  33230. * @returns a number representing the framerate
  33231. */
  33232. getFps(): number;
  33233. /**
  33234. * Gets the time spent between current and previous frame
  33235. * @returns a number representing the delta time in ms
  33236. */
  33237. getDeltaTime(): number;
  33238. private _measureFps;
  33239. /** @hidden */
  33240. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33241. /**
  33242. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  33243. * @param renderTarget The render target to set the frame buffer for
  33244. */
  33245. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  33246. /**
  33247. * Update a dynamic index buffer
  33248. * @param indexBuffer defines the target index buffer
  33249. * @param indices defines the data to update
  33250. * @param offset defines the offset in the target index buffer where update should start
  33251. */
  33252. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33253. /**
  33254. * Updates the sample count of a render target texture
  33255. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33256. * @param texture defines the texture to update
  33257. * @param samples defines the sample count to set
  33258. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33259. */
  33260. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33261. /**
  33262. * Updates a depth texture Comparison Mode and Function.
  33263. * If the comparison Function is equal to 0, the mode will be set to none.
  33264. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33265. * @param texture The texture to set the comparison function for
  33266. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33267. */
  33268. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33269. /**
  33270. * Creates a webGL buffer to use with instanciation
  33271. * @param capacity defines the size of the buffer
  33272. * @returns the webGL buffer
  33273. */
  33274. createInstancesBuffer(capacity: number): DataBuffer;
  33275. /**
  33276. * Delete a webGL buffer used with instanciation
  33277. * @param buffer defines the webGL buffer to delete
  33278. */
  33279. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33280. /** @hidden */
  33281. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33282. dispose(): void;
  33283. private _disableTouchAction;
  33284. /**
  33285. * Display the loading screen
  33286. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33287. */
  33288. displayLoadingUI(): void;
  33289. /**
  33290. * Hide the loading screen
  33291. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33292. */
  33293. hideLoadingUI(): void;
  33294. /**
  33295. * Gets the current loading screen object
  33296. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33297. */
  33298. /**
  33299. * Sets the current loading screen object
  33300. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33301. */
  33302. loadingScreen: ILoadingScreen;
  33303. /**
  33304. * Sets the current loading screen text
  33305. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33306. */
  33307. loadingUIText: string;
  33308. /**
  33309. * Sets the current loading screen background color
  33310. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33311. */
  33312. loadingUIBackgroundColor: string;
  33313. /** Pointerlock and fullscreen */
  33314. /**
  33315. * Ask the browser to promote the current element to pointerlock mode
  33316. * @param element defines the DOM element to promote
  33317. */
  33318. static _RequestPointerlock(element: HTMLElement): void;
  33319. /**
  33320. * Asks the browser to exit pointerlock mode
  33321. */
  33322. static _ExitPointerlock(): void;
  33323. /**
  33324. * Ask the browser to promote the current element to fullscreen rendering mode
  33325. * @param element defines the DOM element to promote
  33326. */
  33327. static _RequestFullscreen(element: HTMLElement): void;
  33328. /**
  33329. * Asks the browser to exit fullscreen mode
  33330. */
  33331. static _ExitFullscreen(): void;
  33332. }
  33333. }
  33334. declare module BABYLON {
  33335. /**
  33336. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33337. * during the life time of the application.
  33338. */
  33339. export class EngineStore {
  33340. /** Gets the list of created engines */
  33341. static Instances: Engine[];
  33342. /** @hidden */
  33343. static _LastCreatedScene: Nullable<Scene>;
  33344. /**
  33345. * Gets the latest created engine
  33346. */
  33347. static readonly LastCreatedEngine: Nullable<Engine>;
  33348. /**
  33349. * Gets the latest created scene
  33350. */
  33351. static readonly LastCreatedScene: Nullable<Scene>;
  33352. /**
  33353. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33354. * @ignorenaming
  33355. */
  33356. static UseFallbackTexture: boolean;
  33357. /**
  33358. * Texture content used if a texture cannot loaded
  33359. * @ignorenaming
  33360. */
  33361. static FallbackTexture: string;
  33362. }
  33363. }
  33364. declare module BABYLON {
  33365. /**
  33366. * Helper class that provides a small promise polyfill
  33367. */
  33368. export class PromisePolyfill {
  33369. /**
  33370. * Static function used to check if the polyfill is required
  33371. * If this is the case then the function will inject the polyfill to window.Promise
  33372. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33373. */
  33374. static Apply(force?: boolean): void;
  33375. }
  33376. }
  33377. declare module BABYLON {
  33378. /**
  33379. * Interface for screenshot methods with describe argument called `size` as object with options
  33380. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33381. */
  33382. export interface IScreenshotSize {
  33383. /**
  33384. * number in pixels for canvas height
  33385. */
  33386. height?: number;
  33387. /**
  33388. * multiplier allowing render at a higher or lower resolution
  33389. * If value is defined then height and width will be ignored and taken from camera
  33390. */
  33391. precision?: number;
  33392. /**
  33393. * number in pixels for canvas width
  33394. */
  33395. width?: number;
  33396. }
  33397. }
  33398. declare module BABYLON {
  33399. interface IColor4Like {
  33400. r: float;
  33401. g: float;
  33402. b: float;
  33403. a: float;
  33404. }
  33405. /**
  33406. * Class containing a set of static utilities functions
  33407. */
  33408. export class Tools {
  33409. /**
  33410. * Gets or sets the base URL to use to load assets
  33411. */
  33412. static BaseUrl: string;
  33413. /**
  33414. * Enable/Disable Custom HTTP Request Headers globally.
  33415. * default = false
  33416. * @see CustomRequestHeaders
  33417. */
  33418. static UseCustomRequestHeaders: boolean;
  33419. /**
  33420. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33421. * i.e. when loading files, where the server/service expects an Authorization header
  33422. */
  33423. static CustomRequestHeaders: {
  33424. [key: string]: string;
  33425. };
  33426. /**
  33427. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33428. */
  33429. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  33430. /**
  33431. * Default behaviour for cors in the application.
  33432. * It can be a string if the expected behavior is identical in the entire app.
  33433. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33434. */
  33435. static CorsBehavior: string | ((url: string | string[]) => string);
  33436. /**
  33437. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33438. * @ignorenaming
  33439. */
  33440. static UseFallbackTexture: boolean;
  33441. /**
  33442. * Use this object to register external classes like custom textures or material
  33443. * to allow the laoders to instantiate them
  33444. */
  33445. static RegisteredExternalClasses: {
  33446. [key: string]: Object;
  33447. };
  33448. /**
  33449. * Texture content used if a texture cannot loaded
  33450. * @ignorenaming
  33451. */
  33452. static fallbackTexture: string;
  33453. /**
  33454. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33455. * @param u defines the coordinate on X axis
  33456. * @param v defines the coordinate on Y axis
  33457. * @param width defines the width of the source data
  33458. * @param height defines the height of the source data
  33459. * @param pixels defines the source byte array
  33460. * @param color defines the output color
  33461. */
  33462. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33463. /**
  33464. * Interpolates between a and b via alpha
  33465. * @param a The lower value (returned when alpha = 0)
  33466. * @param b The upper value (returned when alpha = 1)
  33467. * @param alpha The interpolation-factor
  33468. * @return The mixed value
  33469. */
  33470. static Mix(a: number, b: number, alpha: number): number;
  33471. /**
  33472. * Tries to instantiate a new object from a given class name
  33473. * @param className defines the class name to instantiate
  33474. * @returns the new object or null if the system was not able to do the instantiation
  33475. */
  33476. static Instantiate(className: string): any;
  33477. /**
  33478. * Provides a slice function that will work even on IE
  33479. * @param data defines the array to slice
  33480. * @param start defines the start of the data (optional)
  33481. * @param end defines the end of the data (optional)
  33482. * @returns the new sliced array
  33483. */
  33484. static Slice<T>(data: T, start?: number, end?: number): T;
  33485. /**
  33486. * Polyfill for setImmediate
  33487. * @param action defines the action to execute after the current execution block
  33488. */
  33489. static SetImmediate(action: () => void): void;
  33490. /**
  33491. * Function indicating if a number is an exponent of 2
  33492. * @param value defines the value to test
  33493. * @returns true if the value is an exponent of 2
  33494. */
  33495. static IsExponentOfTwo(value: number): boolean;
  33496. private static _tmpFloatArray;
  33497. /**
  33498. * Returns the nearest 32-bit single precision float representation of a Number
  33499. * @param value A Number. If the parameter is of a different type, it will get converted
  33500. * to a number or to NaN if it cannot be converted
  33501. * @returns number
  33502. */
  33503. static FloatRound(value: number): number;
  33504. /**
  33505. * Extracts the filename from a path
  33506. * @param path defines the path to use
  33507. * @returns the filename
  33508. */
  33509. static GetFilename(path: string): string;
  33510. /**
  33511. * Extracts the "folder" part of a path (everything before the filename).
  33512. * @param uri The URI to extract the info from
  33513. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33514. * @returns The "folder" part of the path
  33515. */
  33516. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33517. /**
  33518. * Extracts text content from a DOM element hierarchy
  33519. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33520. */
  33521. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33522. /**
  33523. * Convert an angle in radians to degrees
  33524. * @param angle defines the angle to convert
  33525. * @returns the angle in degrees
  33526. */
  33527. static ToDegrees(angle: number): number;
  33528. /**
  33529. * Convert an angle in degrees to radians
  33530. * @param angle defines the angle to convert
  33531. * @returns the angle in radians
  33532. */
  33533. static ToRadians(angle: number): number;
  33534. /**
  33535. * Returns an array if obj is not an array
  33536. * @param obj defines the object to evaluate as an array
  33537. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33538. * @returns either obj directly if obj is an array or a new array containing obj
  33539. */
  33540. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33541. /**
  33542. * Gets the pointer prefix to use
  33543. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33544. */
  33545. static GetPointerPrefix(): string;
  33546. /**
  33547. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33548. * @param url define the url we are trying
  33549. * @param element define the dom element where to configure the cors policy
  33550. */
  33551. static SetCorsBehavior(url: string | string[], element: {
  33552. crossOrigin: string | null;
  33553. }): void;
  33554. /**
  33555. * Removes unwanted characters from an url
  33556. * @param url defines the url to clean
  33557. * @returns the cleaned url
  33558. */
  33559. static CleanUrl(url: string): string;
  33560. /**
  33561. * Gets or sets a function used to pre-process url before using them to load assets
  33562. */
  33563. static PreprocessUrl: (url: string) => string;
  33564. /**
  33565. * Loads an image as an HTMLImageElement.
  33566. * @param input url string, ArrayBuffer, or Blob to load
  33567. * @param onLoad callback called when the image successfully loads
  33568. * @param onError callback called when the image fails to load
  33569. * @param offlineProvider offline provider for caching
  33570. * @param mimeType optional mime type
  33571. * @returns the HTMLImageElement of the loaded image
  33572. */
  33573. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33574. /**
  33575. * Loads a file from a url
  33576. * @param url url string, ArrayBuffer, or Blob to load
  33577. * @param onSuccess callback called when the file successfully loads
  33578. * @param onProgress callback called while file is loading (if the server supports this mode)
  33579. * @param offlineProvider defines the offline provider for caching
  33580. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33581. * @param onError callback called when the file fails to load
  33582. * @returns a file request object
  33583. */
  33584. 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;
  33585. /**
  33586. * Loads a file from a url
  33587. * @param url the file url to load
  33588. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33589. */
  33590. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33591. /**
  33592. * Load a script (identified by an url). When the url returns, the
  33593. * content of this file is added into a new script element, attached to the DOM (body element)
  33594. * @param scriptUrl defines the url of the script to laod
  33595. * @param onSuccess defines the callback called when the script is loaded
  33596. * @param onError defines the callback to call if an error occurs
  33597. * @param scriptId defines the id of the script element
  33598. */
  33599. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33600. /**
  33601. * Load an asynchronous script (identified by an url). When the url returns, the
  33602. * content of this file is added into a new script element, attached to the DOM (body element)
  33603. * @param scriptUrl defines the url of the script to laod
  33604. * @param scriptId defines the id of the script element
  33605. * @returns a promise request object
  33606. */
  33607. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33608. /**
  33609. * Loads a file from a blob
  33610. * @param fileToLoad defines the blob to use
  33611. * @param callback defines the callback to call when data is loaded
  33612. * @param progressCallback defines the callback to call during loading process
  33613. * @returns a file request object
  33614. */
  33615. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33616. /**
  33617. * Reads a file from a File object
  33618. * @param file defines the file to load
  33619. * @param onSuccess defines the callback to call when data is loaded
  33620. * @param onProgress defines the callback to call during loading process
  33621. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33622. * @param onError defines the callback to call when an error occurs
  33623. * @returns a file request object
  33624. */
  33625. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33626. /**
  33627. * Creates a data url from a given string content
  33628. * @param content defines the content to convert
  33629. * @returns the new data url link
  33630. */
  33631. static FileAsURL(content: string): string;
  33632. /**
  33633. * Format the given number to a specific decimal format
  33634. * @param value defines the number to format
  33635. * @param decimals defines the number of decimals to use
  33636. * @returns the formatted string
  33637. */
  33638. static Format(value: number, decimals?: number): string;
  33639. /**
  33640. * Tries to copy an object by duplicating every property
  33641. * @param source defines the source object
  33642. * @param destination defines the target object
  33643. * @param doNotCopyList defines a list of properties to avoid
  33644. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33645. */
  33646. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33647. /**
  33648. * Gets a boolean indicating if the given object has no own property
  33649. * @param obj defines the object to test
  33650. * @returns true if object has no own property
  33651. */
  33652. static IsEmpty(obj: any): boolean;
  33653. /**
  33654. * Function used to register events at window level
  33655. * @param windowElement defines the Window object to use
  33656. * @param events defines the events to register
  33657. */
  33658. static RegisterTopRootEvents(windowElement: Window, events: {
  33659. name: string;
  33660. handler: Nullable<(e: FocusEvent) => any>;
  33661. }[]): void;
  33662. /**
  33663. * Function used to unregister events from window level
  33664. * @param windowElement defines the Window object to use
  33665. * @param events defines the events to unregister
  33666. */
  33667. static UnregisterTopRootEvents(windowElement: Window, events: {
  33668. name: string;
  33669. handler: Nullable<(e: FocusEvent) => any>;
  33670. }[]): void;
  33671. /**
  33672. * @ignore
  33673. */
  33674. static _ScreenshotCanvas: HTMLCanvasElement;
  33675. /**
  33676. * Dumps the current bound framebuffer
  33677. * @param width defines the rendering width
  33678. * @param height defines the rendering height
  33679. * @param engine defines the hosting engine
  33680. * @param successCallback defines the callback triggered once the data are available
  33681. * @param mimeType defines the mime type of the result
  33682. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33683. */
  33684. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33685. /**
  33686. * Converts the canvas data to blob.
  33687. * This acts as a polyfill for browsers not supporting the to blob function.
  33688. * @param canvas Defines the canvas to extract the data from
  33689. * @param successCallback Defines the callback triggered once the data are available
  33690. * @param mimeType Defines the mime type of the result
  33691. */
  33692. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33693. /**
  33694. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  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 he filename to download. If present, the result will automatically be downloaded
  33698. */
  33699. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33700. /**
  33701. * Downloads a blob in the browser
  33702. * @param blob defines the blob to download
  33703. * @param fileName defines the name of the downloaded file
  33704. */
  33705. static Download(blob: Blob, fileName: string): void;
  33706. /**
  33707. * Captures a screenshot of the current rendering
  33708. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33709. * @param engine defines the rendering engine
  33710. * @param camera defines the source camera
  33711. * @param size This parameter can be set to a single number or to an object with the
  33712. * following (optional) properties: precision, width, height. If a single number is passed,
  33713. * it will be used for both width and height. If an object is passed, the screenshot size
  33714. * will be derived from the parameters. The precision property is a multiplier allowing
  33715. * rendering at a higher or lower resolution
  33716. * @param successCallback defines the callback receives a single parameter which contains the
  33717. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33718. * src parameter of an <img> to display it
  33719. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33720. * Check your browser for supported MIME types
  33721. */
  33722. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33723. /**
  33724. * Captures a screenshot of the current rendering
  33725. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33726. * @param engine defines the rendering engine
  33727. * @param camera defines the source camera
  33728. * @param size This parameter can be set to a single number or to an object with the
  33729. * following (optional) properties: precision, width, height. If a single number is passed,
  33730. * it will be used for both width and height. If an object is passed, the screenshot size
  33731. * will be derived from the parameters. The precision property is a multiplier allowing
  33732. * rendering at a higher or lower resolution
  33733. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33734. * Check your browser for supported MIME types
  33735. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33736. * to the src parameter of an <img> to display it
  33737. */
  33738. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33739. /**
  33740. * Generates an image screenshot from the specified camera.
  33741. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33742. * @param engine The engine to use for rendering
  33743. * @param camera The camera to use for rendering
  33744. * @param size This parameter can be set to a single number or to an object with the
  33745. * following (optional) properties: precision, width, height. If a single number is passed,
  33746. * it will be used for both width and height. If an object is passed, the screenshot size
  33747. * will be derived from the parameters. The precision property is a multiplier allowing
  33748. * rendering at a higher or lower resolution
  33749. * @param successCallback The callback receives a single parameter which contains the
  33750. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33751. * src parameter of an <img> to display it
  33752. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33753. * Check your browser for supported MIME types
  33754. * @param samples Texture samples (default: 1)
  33755. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33756. * @param fileName A name for for the downloaded file.
  33757. */
  33758. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33759. /**
  33760. * Generates an image screenshot from the specified camera.
  33761. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33762. * @param engine The engine to use for rendering
  33763. * @param camera The camera to use for rendering
  33764. * @param size This parameter can be set to a single number or to an object with the
  33765. * following (optional) properties: precision, width, height. If a single number is passed,
  33766. * it will be used for both width and height. If an object is passed, the screenshot size
  33767. * will be derived from the parameters. The precision property is a multiplier allowing
  33768. * rendering at a higher or lower resolution
  33769. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33770. * Check your browser for supported MIME types
  33771. * @param samples Texture samples (default: 1)
  33772. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33773. * @param fileName A name for for the downloaded file.
  33774. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33775. * to the src parameter of an <img> to display it
  33776. */
  33777. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33778. /**
  33779. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33780. * Be aware Math.random() could cause collisions, but:
  33781. * "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"
  33782. * @returns a pseudo random id
  33783. */
  33784. static RandomId(): string;
  33785. /**
  33786. * Test if the given uri is a base64 string
  33787. * @param uri The uri to test
  33788. * @return True if the uri is a base64 string or false otherwise
  33789. */
  33790. static IsBase64(uri: string): boolean;
  33791. /**
  33792. * Decode the given base64 uri.
  33793. * @param uri The uri to decode
  33794. * @return The decoded base64 data.
  33795. */
  33796. static DecodeBase64(uri: string): ArrayBuffer;
  33797. /**
  33798. * Gets the absolute url.
  33799. * @param url the input url
  33800. * @return the absolute url
  33801. */
  33802. static GetAbsoluteUrl(url: string): string;
  33803. /**
  33804. * No log
  33805. */
  33806. static readonly NoneLogLevel: number;
  33807. /**
  33808. * Only message logs
  33809. */
  33810. static readonly MessageLogLevel: number;
  33811. /**
  33812. * Only warning logs
  33813. */
  33814. static readonly WarningLogLevel: number;
  33815. /**
  33816. * Only error logs
  33817. */
  33818. static readonly ErrorLogLevel: number;
  33819. /**
  33820. * All logs
  33821. */
  33822. static readonly AllLogLevel: number;
  33823. /**
  33824. * Gets a value indicating the number of loading errors
  33825. * @ignorenaming
  33826. */
  33827. static readonly errorsCount: number;
  33828. /**
  33829. * Callback called when a new log is added
  33830. */
  33831. static OnNewCacheEntry: (entry: string) => void;
  33832. /**
  33833. * Log a message to the console
  33834. * @param message defines the message to log
  33835. */
  33836. static Log(message: string): void;
  33837. /**
  33838. * Write a warning message to the console
  33839. * @param message defines the message to log
  33840. */
  33841. static Warn(message: string): void;
  33842. /**
  33843. * Write an error message to the console
  33844. * @param message defines the message to log
  33845. */
  33846. static Error(message: string): void;
  33847. /**
  33848. * Gets current log cache (list of logs)
  33849. */
  33850. static readonly LogCache: string;
  33851. /**
  33852. * Clears the log cache
  33853. */
  33854. static ClearLogCache(): void;
  33855. /**
  33856. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33857. */
  33858. static LogLevels: number;
  33859. /**
  33860. * Checks if the window object exists
  33861. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33862. */
  33863. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33864. /**
  33865. * No performance log
  33866. */
  33867. static readonly PerformanceNoneLogLevel: number;
  33868. /**
  33869. * Use user marks to log performance
  33870. */
  33871. static readonly PerformanceUserMarkLogLevel: number;
  33872. /**
  33873. * Log performance to the console
  33874. */
  33875. static readonly PerformanceConsoleLogLevel: number;
  33876. private static _performance;
  33877. /**
  33878. * Sets the current performance log level
  33879. */
  33880. static PerformanceLogLevel: number;
  33881. private static _StartPerformanceCounterDisabled;
  33882. private static _EndPerformanceCounterDisabled;
  33883. private static _StartUserMark;
  33884. private static _EndUserMark;
  33885. private static _StartPerformanceConsole;
  33886. private static _EndPerformanceConsole;
  33887. /**
  33888. * Starts a performance counter
  33889. */
  33890. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33891. /**
  33892. * Ends a specific performance coutner
  33893. */
  33894. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33895. /**
  33896. * Gets either window.performance.now() if supported or Date.now() else
  33897. */
  33898. static readonly Now: number;
  33899. /**
  33900. * This method will return the name of the class used to create the instance of the given object.
  33901. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33902. * @param object the object to get the class name from
  33903. * @param isType defines if the object is actually a type
  33904. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33905. */
  33906. static GetClassName(object: any, isType?: boolean): string;
  33907. /**
  33908. * Gets the first element of an array satisfying a given predicate
  33909. * @param array defines the array to browse
  33910. * @param predicate defines the predicate to use
  33911. * @returns null if not found or the element
  33912. */
  33913. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33914. /**
  33915. * This method will return the name of the full name of the class, including its owning module (if any).
  33916. * 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).
  33917. * @param object the object to get the class name from
  33918. * @param isType defines if the object is actually a type
  33919. * @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.
  33920. * @ignorenaming
  33921. */
  33922. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33923. /**
  33924. * Returns a promise that resolves after the given amount of time.
  33925. * @param delay Number of milliseconds to delay
  33926. * @returns Promise that resolves after the given amount of time
  33927. */
  33928. static DelayAsync(delay: number): Promise<void>;
  33929. }
  33930. /**
  33931. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33932. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33933. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33934. * @param name The name of the class, case should be preserved
  33935. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33936. */
  33937. export function className(name: string, module?: string): (target: Object) => void;
  33938. /**
  33939. * An implementation of a loop for asynchronous functions.
  33940. */
  33941. export class AsyncLoop {
  33942. /**
  33943. * Defines the number of iterations for the loop
  33944. */
  33945. iterations: number;
  33946. /**
  33947. * Defines the current index of the loop.
  33948. */
  33949. index: number;
  33950. private _done;
  33951. private _fn;
  33952. private _successCallback;
  33953. /**
  33954. * Constructor.
  33955. * @param iterations the number of iterations.
  33956. * @param func the function to run each iteration
  33957. * @param successCallback the callback that will be called upon succesful execution
  33958. * @param offset starting offset.
  33959. */
  33960. constructor(
  33961. /**
  33962. * Defines the number of iterations for the loop
  33963. */
  33964. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33965. /**
  33966. * Execute the next iteration. Must be called after the last iteration was finished.
  33967. */
  33968. executeNext(): void;
  33969. /**
  33970. * Break the loop and run the success callback.
  33971. */
  33972. breakLoop(): void;
  33973. /**
  33974. * Create and run an async loop.
  33975. * @param iterations the number of iterations.
  33976. * @param fn the function to run each iteration
  33977. * @param successCallback the callback that will be called upon succesful execution
  33978. * @param offset starting offset.
  33979. * @returns the created async loop object
  33980. */
  33981. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33982. /**
  33983. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33984. * @param iterations total number of iterations
  33985. * @param syncedIterations number of synchronous iterations in each async iteration.
  33986. * @param fn the function to call each iteration.
  33987. * @param callback a success call back that will be called when iterating stops.
  33988. * @param breakFunction a break condition (optional)
  33989. * @param timeout timeout settings for the setTimeout function. default - 0.
  33990. * @returns the created async loop object
  33991. */
  33992. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33993. }
  33994. }
  33995. declare module BABYLON {
  33996. /**
  33997. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33998. * The underlying implementation relies on an associative array to ensure the best performances.
  33999. * The value can be anything including 'null' but except 'undefined'
  34000. */
  34001. export class StringDictionary<T> {
  34002. /**
  34003. * This will clear this dictionary and copy the content from the 'source' one.
  34004. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34005. * @param source the dictionary to take the content from and copy to this dictionary
  34006. */
  34007. copyFrom(source: StringDictionary<T>): void;
  34008. /**
  34009. * Get a value based from its key
  34010. * @param key the given key to get the matching value from
  34011. * @return the value if found, otherwise undefined is returned
  34012. */
  34013. get(key: string): T | undefined;
  34014. /**
  34015. * Get a value from its key or add it if it doesn't exist.
  34016. * This method will ensure you that a given key/data will be present in the dictionary.
  34017. * @param key the given key to get the matching value from
  34018. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34019. * The factory will only be invoked if there's no data for the given key.
  34020. * @return the value corresponding to the key.
  34021. */
  34022. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34023. /**
  34024. * Get a value from its key if present in the dictionary otherwise add it
  34025. * @param key the key to get the value from
  34026. * @param val if there's no such key/value pair in the dictionary add it with this value
  34027. * @return the value corresponding to the key
  34028. */
  34029. getOrAdd(key: string, val: T): T;
  34030. /**
  34031. * Check if there's a given key in the dictionary
  34032. * @param key the key to check for
  34033. * @return true if the key is present, false otherwise
  34034. */
  34035. contains(key: string): boolean;
  34036. /**
  34037. * Add a new key and its corresponding value
  34038. * @param key the key to add
  34039. * @param value the value corresponding to the key
  34040. * @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
  34041. */
  34042. add(key: string, value: T): boolean;
  34043. /**
  34044. * Update a specific value associated to a key
  34045. * @param key defines the key to use
  34046. * @param value defines the value to store
  34047. * @returns true if the value was updated (or false if the key was not found)
  34048. */
  34049. set(key: string, value: T): boolean;
  34050. /**
  34051. * Get the element of the given key and remove it from the dictionary
  34052. * @param key defines the key to search
  34053. * @returns the value associated with the key or null if not found
  34054. */
  34055. getAndRemove(key: string): Nullable<T>;
  34056. /**
  34057. * Remove a key/value from the dictionary.
  34058. * @param key the key to remove
  34059. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34060. */
  34061. remove(key: string): boolean;
  34062. /**
  34063. * Clear the whole content of the dictionary
  34064. */
  34065. clear(): void;
  34066. /**
  34067. * Gets the current count
  34068. */
  34069. readonly count: number;
  34070. /**
  34071. * Execute a callback on each key/val of the dictionary.
  34072. * Note that you can remove any element in this dictionary in the callback implementation
  34073. * @param callback the callback to execute on a given key/value pair
  34074. */
  34075. forEach(callback: (key: string, val: T) => void): void;
  34076. /**
  34077. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34078. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34079. * Note that you can remove any element in this dictionary in the callback implementation
  34080. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34081. * @returns the first item
  34082. */
  34083. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34084. private _count;
  34085. private _data;
  34086. }
  34087. }
  34088. declare module BABYLON {
  34089. /** @hidden */
  34090. export interface ICollisionCoordinator {
  34091. createCollider(): Collider;
  34092. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34093. init(scene: Scene): void;
  34094. }
  34095. /** @hidden */
  34096. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34097. private _scene;
  34098. private _scaledPosition;
  34099. private _scaledVelocity;
  34100. private _finalPosition;
  34101. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34102. createCollider(): Collider;
  34103. init(scene: Scene): void;
  34104. private _collideWithWorld;
  34105. }
  34106. }
  34107. declare module BABYLON {
  34108. /**
  34109. * Class used to manage all inputs for the scene.
  34110. */
  34111. export class InputManager {
  34112. /** The distance in pixel that you have to move to prevent some events */
  34113. static DragMovementThreshold: number;
  34114. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34115. static LongPressDelay: number;
  34116. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34117. static DoubleClickDelay: number;
  34118. /** If you need to check double click without raising a single click at first click, enable this flag */
  34119. static ExclusiveDoubleClickMode: boolean;
  34120. private _wheelEventName;
  34121. private _onPointerMove;
  34122. private _onPointerDown;
  34123. private _onPointerUp;
  34124. private _initClickEvent;
  34125. private _initActionManager;
  34126. private _delayedSimpleClick;
  34127. private _delayedSimpleClickTimeout;
  34128. private _previousDelayedSimpleClickTimeout;
  34129. private _meshPickProceed;
  34130. private _previousButtonPressed;
  34131. private _currentPickResult;
  34132. private _previousPickResult;
  34133. private _totalPointersPressed;
  34134. private _doubleClickOccured;
  34135. private _pointerOverMesh;
  34136. private _pickedDownMesh;
  34137. private _pickedUpMesh;
  34138. private _pointerX;
  34139. private _pointerY;
  34140. private _unTranslatedPointerX;
  34141. private _unTranslatedPointerY;
  34142. private _startingPointerPosition;
  34143. private _previousStartingPointerPosition;
  34144. private _startingPointerTime;
  34145. private _previousStartingPointerTime;
  34146. private _pointerCaptures;
  34147. private _onKeyDown;
  34148. private _onKeyUp;
  34149. private _onCanvasFocusObserver;
  34150. private _onCanvasBlurObserver;
  34151. private _scene;
  34152. /**
  34153. * Creates a new InputManager
  34154. * @param scene defines the hosting scene
  34155. */
  34156. constructor(scene: Scene);
  34157. /**
  34158. * Gets the mesh that is currently under the pointer
  34159. */
  34160. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34161. /**
  34162. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34163. */
  34164. readonly unTranslatedPointer: Vector2;
  34165. /**
  34166. * Gets or sets the current on-screen X position of the pointer
  34167. */
  34168. pointerX: number;
  34169. /**
  34170. * Gets or sets the current on-screen Y position of the pointer
  34171. */
  34172. pointerY: number;
  34173. private _updatePointerPosition;
  34174. private _processPointerMove;
  34175. private _setRayOnPointerInfo;
  34176. private _checkPrePointerObservable;
  34177. /**
  34178. * Use this method to simulate a pointer move on a mesh
  34179. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34180. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34181. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34182. */
  34183. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34184. /**
  34185. * Use this method to simulate a pointer down on a mesh
  34186. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34187. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34188. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34189. */
  34190. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34191. private _processPointerDown;
  34192. /** @hidden */
  34193. _isPointerSwiping(): boolean;
  34194. /**
  34195. * Use this method to simulate a pointer up on a mesh
  34196. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34197. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34198. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34199. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34200. */
  34201. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34202. private _processPointerUp;
  34203. /**
  34204. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34205. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34206. * @returns true if the pointer was captured
  34207. */
  34208. isPointerCaptured(pointerId?: number): boolean;
  34209. /**
  34210. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34211. * @param attachUp defines if you want to attach events to pointerup
  34212. * @param attachDown defines if you want to attach events to pointerdown
  34213. * @param attachMove defines if you want to attach events to pointermove
  34214. */
  34215. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34216. /**
  34217. * Detaches all event handlers
  34218. */
  34219. detachControl(): void;
  34220. /**
  34221. * Force the value of meshUnderPointer
  34222. * @param mesh defines the mesh to use
  34223. */
  34224. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34225. /**
  34226. * Gets the mesh under the pointer
  34227. * @returns a Mesh or null if no mesh is under the pointer
  34228. */
  34229. getPointerOverMesh(): Nullable<AbstractMesh>;
  34230. }
  34231. }
  34232. declare module BABYLON {
  34233. /**
  34234. * Helper class used to generate session unique ID
  34235. */
  34236. export class UniqueIdGenerator {
  34237. private static _UniqueIdCounter;
  34238. /**
  34239. * Gets an unique (relatively to the current scene) Id
  34240. */
  34241. static readonly UniqueId: number;
  34242. }
  34243. }
  34244. declare module BABYLON {
  34245. /**
  34246. * This class defines the direct association between an animation and a target
  34247. */
  34248. export class TargetedAnimation {
  34249. /**
  34250. * Animation to perform
  34251. */
  34252. animation: Animation;
  34253. /**
  34254. * Target to animate
  34255. */
  34256. target: any;
  34257. /**
  34258. * Serialize the object
  34259. * @returns the JSON object representing the current entity
  34260. */
  34261. serialize(): any;
  34262. }
  34263. /**
  34264. * Use this class to create coordinated animations on multiple targets
  34265. */
  34266. export class AnimationGroup implements IDisposable {
  34267. /** The name of the animation group */
  34268. name: string;
  34269. private _scene;
  34270. private _targetedAnimations;
  34271. private _animatables;
  34272. private _from;
  34273. private _to;
  34274. private _isStarted;
  34275. private _isPaused;
  34276. private _speedRatio;
  34277. private _loopAnimation;
  34278. /**
  34279. * Gets or sets the unique id of the node
  34280. */
  34281. uniqueId: number;
  34282. /**
  34283. * This observable will notify when one animation have ended
  34284. */
  34285. onAnimationEndObservable: Observable<TargetedAnimation>;
  34286. /**
  34287. * Observer raised when one animation loops
  34288. */
  34289. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34290. /**
  34291. * Observer raised when all animations have looped
  34292. */
  34293. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34294. /**
  34295. * This observable will notify when all animations have ended.
  34296. */
  34297. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34298. /**
  34299. * This observable will notify when all animations have paused.
  34300. */
  34301. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34302. /**
  34303. * This observable will notify when all animations are playing.
  34304. */
  34305. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34306. /**
  34307. * Gets the first frame
  34308. */
  34309. readonly from: number;
  34310. /**
  34311. * Gets the last frame
  34312. */
  34313. readonly to: number;
  34314. /**
  34315. * Define if the animations are started
  34316. */
  34317. readonly isStarted: boolean;
  34318. /**
  34319. * Gets a value indicating that the current group is playing
  34320. */
  34321. readonly isPlaying: boolean;
  34322. /**
  34323. * Gets or sets the speed ratio to use for all animations
  34324. */
  34325. /**
  34326. * Gets or sets the speed ratio to use for all animations
  34327. */
  34328. speedRatio: number;
  34329. /**
  34330. * Gets or sets if all animations should loop or not
  34331. */
  34332. loopAnimation: boolean;
  34333. /**
  34334. * Gets the targeted animations for this animation group
  34335. */
  34336. readonly targetedAnimations: Array<TargetedAnimation>;
  34337. /**
  34338. * returning the list of animatables controlled by this animation group.
  34339. */
  34340. readonly animatables: Array<Animatable>;
  34341. /**
  34342. * Instantiates a new Animation Group.
  34343. * This helps managing several animations at once.
  34344. * @see http://doc.babylonjs.com/how_to/group
  34345. * @param name Defines the name of the group
  34346. * @param scene Defines the scene the group belongs to
  34347. */
  34348. constructor(
  34349. /** The name of the animation group */
  34350. name: string, scene?: Nullable<Scene>);
  34351. /**
  34352. * Add an animation (with its target) in the group
  34353. * @param animation defines the animation we want to add
  34354. * @param target defines the target of the animation
  34355. * @returns the TargetedAnimation object
  34356. */
  34357. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34358. /**
  34359. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34360. * It can add constant keys at begin or end
  34361. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34362. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34363. * @returns the animation group
  34364. */
  34365. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34366. private _animationLoopCount;
  34367. private _animationLoopFlags;
  34368. private _processLoop;
  34369. /**
  34370. * Start all animations on given targets
  34371. * @param loop defines if animations must loop
  34372. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34373. * @param from defines the from key (optional)
  34374. * @param to defines the to key (optional)
  34375. * @returns the current animation group
  34376. */
  34377. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34378. /**
  34379. * Pause all animations
  34380. * @returns the animation group
  34381. */
  34382. pause(): AnimationGroup;
  34383. /**
  34384. * Play all animations to initial state
  34385. * This function will start() the animations if they were not started or will restart() them if they were paused
  34386. * @param loop defines if animations must loop
  34387. * @returns the animation group
  34388. */
  34389. play(loop?: boolean): AnimationGroup;
  34390. /**
  34391. * Reset all animations to initial state
  34392. * @returns the animation group
  34393. */
  34394. reset(): AnimationGroup;
  34395. /**
  34396. * Restart animations from key 0
  34397. * @returns the animation group
  34398. */
  34399. restart(): AnimationGroup;
  34400. /**
  34401. * Stop all animations
  34402. * @returns the animation group
  34403. */
  34404. stop(): AnimationGroup;
  34405. /**
  34406. * Set animation weight for all animatables
  34407. * @param weight defines the weight to use
  34408. * @return the animationGroup
  34409. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34410. */
  34411. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34412. /**
  34413. * Synchronize and normalize all animatables with a source animatable
  34414. * @param root defines the root animatable to synchronize with
  34415. * @return the animationGroup
  34416. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34417. */
  34418. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34419. /**
  34420. * Goes to a specific frame in this animation group
  34421. * @param frame the frame number to go to
  34422. * @return the animationGroup
  34423. */
  34424. goToFrame(frame: number): AnimationGroup;
  34425. /**
  34426. * Dispose all associated resources
  34427. */
  34428. dispose(): void;
  34429. private _checkAnimationGroupEnded;
  34430. /**
  34431. * Clone the current animation group and returns a copy
  34432. * @param newName defines the name of the new group
  34433. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34434. * @returns the new aniamtion group
  34435. */
  34436. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34437. /**
  34438. * Serializes the animationGroup to an object
  34439. * @returns Serialized object
  34440. */
  34441. serialize(): any;
  34442. /**
  34443. * Returns a new AnimationGroup object parsed from the source provided.
  34444. * @param parsedAnimationGroup defines the source
  34445. * @param scene defines the scene that will receive the animationGroup
  34446. * @returns a new AnimationGroup
  34447. */
  34448. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34449. /**
  34450. * Returns the string "AnimationGroup"
  34451. * @returns "AnimationGroup"
  34452. */
  34453. getClassName(): string;
  34454. /**
  34455. * Creates a detailled string about the object
  34456. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34457. * @returns a string representing the object
  34458. */
  34459. toString(fullDetails?: boolean): string;
  34460. }
  34461. }
  34462. declare module BABYLON {
  34463. /**
  34464. * Define an interface for all classes that will hold resources
  34465. */
  34466. export interface IDisposable {
  34467. /**
  34468. * Releases all held resources
  34469. */
  34470. dispose(): void;
  34471. }
  34472. /** Interface defining initialization parameters for Scene class */
  34473. export interface SceneOptions {
  34474. /**
  34475. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34476. * It will improve performance when the number of geometries becomes important.
  34477. */
  34478. useGeometryUniqueIdsMap?: boolean;
  34479. /**
  34480. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34481. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34482. */
  34483. useMaterialMeshMap?: boolean;
  34484. /**
  34485. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34486. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34487. */
  34488. useClonedMeshhMap?: boolean;
  34489. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34490. virtual?: boolean;
  34491. }
  34492. /**
  34493. * Represents a scene to be rendered by the engine.
  34494. * @see http://doc.babylonjs.com/features/scene
  34495. */
  34496. export class Scene extends AbstractScene implements IAnimatable {
  34497. /** The fog is deactivated */
  34498. static readonly FOGMODE_NONE: number;
  34499. /** The fog density is following an exponential function */
  34500. static readonly FOGMODE_EXP: number;
  34501. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34502. static readonly FOGMODE_EXP2: number;
  34503. /** The fog density is following a linear function. */
  34504. static readonly FOGMODE_LINEAR: number;
  34505. /**
  34506. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34507. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34508. */
  34509. static MinDeltaTime: number;
  34510. /**
  34511. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34512. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34513. */
  34514. static MaxDeltaTime: number;
  34515. /**
  34516. * Factory used to create the default material.
  34517. * @param name The name of the material to create
  34518. * @param scene The scene to create the material for
  34519. * @returns The default material
  34520. */
  34521. static DefaultMaterialFactory(scene: Scene): Material;
  34522. /**
  34523. * Factory used to create the a collision coordinator.
  34524. * @returns The collision coordinator
  34525. */
  34526. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34527. /** @hidden */
  34528. _inputManager: InputManager;
  34529. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34530. cameraToUseForPointers: Nullable<Camera>;
  34531. /** @hidden */
  34532. readonly _isScene: boolean;
  34533. /**
  34534. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34535. */
  34536. autoClear: boolean;
  34537. /**
  34538. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34539. */
  34540. autoClearDepthAndStencil: boolean;
  34541. /**
  34542. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34543. */
  34544. clearColor: Color4;
  34545. /**
  34546. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34547. */
  34548. ambientColor: Color3;
  34549. /**
  34550. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34551. * It should only be one of the following (if not the default embedded one):
  34552. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34553. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34554. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34555. * The material properties need to be setup according to the type of texture in use.
  34556. */
  34557. environmentBRDFTexture: BaseTexture;
  34558. /** @hidden */
  34559. protected _environmentTexture: Nullable<BaseTexture>;
  34560. /**
  34561. * Texture used in all pbr material as the reflection texture.
  34562. * As in the majority of the scene they are the same (exception for multi room and so on),
  34563. * this is easier to reference from here than from all the materials.
  34564. */
  34565. /**
  34566. * Texture used in all pbr material as the reflection texture.
  34567. * As in the majority of the scene they are the same (exception for multi room and so on),
  34568. * this is easier to set here than in all the materials.
  34569. */
  34570. environmentTexture: Nullable<BaseTexture>;
  34571. /** @hidden */
  34572. protected _environmentIntensity: number;
  34573. /**
  34574. * Intensity of the environment in all pbr material.
  34575. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34576. * As in the majority of the scene they are the same (exception for multi room and so on),
  34577. * this is easier to reference from here than from all the materials.
  34578. */
  34579. /**
  34580. * Intensity of the environment in all pbr material.
  34581. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  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. environmentIntensity: number;
  34586. /** @hidden */
  34587. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34588. /**
  34589. * Default image processing configuration used either in the rendering
  34590. * Forward main pass or through the imageProcessingPostProcess if present.
  34591. * As in the majority of the scene they are the same (exception for multi camera),
  34592. * this is easier to reference from here than from all the materials and post process.
  34593. *
  34594. * No setter as we it is a shared configuration, you can set the values instead.
  34595. */
  34596. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34597. private _forceWireframe;
  34598. /**
  34599. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34600. */
  34601. forceWireframe: boolean;
  34602. private _forcePointsCloud;
  34603. /**
  34604. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34605. */
  34606. forcePointsCloud: boolean;
  34607. /**
  34608. * Gets or sets the active clipplane 1
  34609. */
  34610. clipPlane: Nullable<Plane>;
  34611. /**
  34612. * Gets or sets the active clipplane 2
  34613. */
  34614. clipPlane2: Nullable<Plane>;
  34615. /**
  34616. * Gets or sets the active clipplane 3
  34617. */
  34618. clipPlane3: Nullable<Plane>;
  34619. /**
  34620. * Gets or sets the active clipplane 4
  34621. */
  34622. clipPlane4: Nullable<Plane>;
  34623. /**
  34624. * Gets or sets a boolean indicating if animations are enabled
  34625. */
  34626. animationsEnabled: boolean;
  34627. private _animationPropertiesOverride;
  34628. /**
  34629. * Gets or sets the animation properties override
  34630. */
  34631. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34632. /**
  34633. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34634. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34635. */
  34636. useConstantAnimationDeltaTime: boolean;
  34637. /**
  34638. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34639. * Please note that it requires to run a ray cast through the scene on every frame
  34640. */
  34641. constantlyUpdateMeshUnderPointer: boolean;
  34642. /**
  34643. * Defines the HTML cursor to use when hovering over interactive elements
  34644. */
  34645. hoverCursor: string;
  34646. /**
  34647. * Defines the HTML default cursor to use (empty by default)
  34648. */
  34649. defaultCursor: string;
  34650. /**
  34651. * Defines wether cursors are handled by the scene.
  34652. */
  34653. doNotHandleCursors: boolean;
  34654. /**
  34655. * This is used to call preventDefault() on pointer down
  34656. * in order to block unwanted artifacts like system double clicks
  34657. */
  34658. preventDefaultOnPointerDown: boolean;
  34659. /**
  34660. * This is used to call preventDefault() on pointer up
  34661. * in order to block unwanted artifacts like system double clicks
  34662. */
  34663. preventDefaultOnPointerUp: boolean;
  34664. /**
  34665. * Gets or sets user defined metadata
  34666. */
  34667. metadata: any;
  34668. /**
  34669. * For internal use only. Please do not use.
  34670. */
  34671. reservedDataStore: any;
  34672. /**
  34673. * Gets the name of the plugin used to load this scene (null by default)
  34674. */
  34675. loadingPluginName: string;
  34676. /**
  34677. * Use this array to add regular expressions used to disable offline support for specific urls
  34678. */
  34679. disableOfflineSupportExceptionRules: RegExp[];
  34680. /**
  34681. * An event triggered when the scene is disposed.
  34682. */
  34683. onDisposeObservable: Observable<Scene>;
  34684. private _onDisposeObserver;
  34685. /** Sets a function to be executed when this scene is disposed. */
  34686. onDispose: () => void;
  34687. /**
  34688. * An event triggered before rendering the scene (right after animations and physics)
  34689. */
  34690. onBeforeRenderObservable: Observable<Scene>;
  34691. private _onBeforeRenderObserver;
  34692. /** Sets a function to be executed before rendering this scene */
  34693. beforeRender: Nullable<() => void>;
  34694. /**
  34695. * An event triggered after rendering the scene
  34696. */
  34697. onAfterRenderObservable: Observable<Scene>;
  34698. /**
  34699. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34700. */
  34701. onAfterRenderCameraObservable: Observable<Camera>;
  34702. private _onAfterRenderObserver;
  34703. /** Sets a function to be executed after rendering this scene */
  34704. afterRender: Nullable<() => void>;
  34705. /**
  34706. * An event triggered before animating the scene
  34707. */
  34708. onBeforeAnimationsObservable: Observable<Scene>;
  34709. /**
  34710. * An event triggered after animations processing
  34711. */
  34712. onAfterAnimationsObservable: Observable<Scene>;
  34713. /**
  34714. * An event triggered before draw calls are ready to be sent
  34715. */
  34716. onBeforeDrawPhaseObservable: Observable<Scene>;
  34717. /**
  34718. * An event triggered after draw calls have been sent
  34719. */
  34720. onAfterDrawPhaseObservable: Observable<Scene>;
  34721. /**
  34722. * An event triggered when the scene is ready
  34723. */
  34724. onReadyObservable: Observable<Scene>;
  34725. /**
  34726. * An event triggered before rendering a camera
  34727. */
  34728. onBeforeCameraRenderObservable: Observable<Camera>;
  34729. private _onBeforeCameraRenderObserver;
  34730. /** Sets a function to be executed before rendering a camera*/
  34731. beforeCameraRender: () => void;
  34732. /**
  34733. * An event triggered after rendering a camera
  34734. */
  34735. onAfterCameraRenderObservable: Observable<Camera>;
  34736. private _onAfterCameraRenderObserver;
  34737. /** Sets a function to be executed after rendering a camera*/
  34738. afterCameraRender: () => void;
  34739. /**
  34740. * An event triggered when active meshes evaluation is about to start
  34741. */
  34742. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34743. /**
  34744. * An event triggered when active meshes evaluation is done
  34745. */
  34746. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34747. /**
  34748. * An event triggered when particles rendering is about to start
  34749. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34750. */
  34751. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34752. /**
  34753. * An event triggered when particles rendering is done
  34754. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34755. */
  34756. onAfterParticlesRenderingObservable: Observable<Scene>;
  34757. /**
  34758. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34759. */
  34760. onDataLoadedObservable: Observable<Scene>;
  34761. /**
  34762. * An event triggered when a camera is created
  34763. */
  34764. onNewCameraAddedObservable: Observable<Camera>;
  34765. /**
  34766. * An event triggered when a camera is removed
  34767. */
  34768. onCameraRemovedObservable: Observable<Camera>;
  34769. /**
  34770. * An event triggered when a light is created
  34771. */
  34772. onNewLightAddedObservable: Observable<Light>;
  34773. /**
  34774. * An event triggered when a light is removed
  34775. */
  34776. onLightRemovedObservable: Observable<Light>;
  34777. /**
  34778. * An event triggered when a geometry is created
  34779. */
  34780. onNewGeometryAddedObservable: Observable<Geometry>;
  34781. /**
  34782. * An event triggered when a geometry is removed
  34783. */
  34784. onGeometryRemovedObservable: Observable<Geometry>;
  34785. /**
  34786. * An event triggered when a transform node is created
  34787. */
  34788. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34789. /**
  34790. * An event triggered when a transform node is removed
  34791. */
  34792. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34793. /**
  34794. * An event triggered when a mesh is created
  34795. */
  34796. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34797. /**
  34798. * An event triggered when a mesh is removed
  34799. */
  34800. onMeshRemovedObservable: Observable<AbstractMesh>;
  34801. /**
  34802. * An event triggered when a skeleton is created
  34803. */
  34804. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34805. /**
  34806. * An event triggered when a skeleton is removed
  34807. */
  34808. onSkeletonRemovedObservable: Observable<Skeleton>;
  34809. /**
  34810. * An event triggered when a material is created
  34811. */
  34812. onNewMaterialAddedObservable: Observable<Material>;
  34813. /**
  34814. * An event triggered when a material is removed
  34815. */
  34816. onMaterialRemovedObservable: Observable<Material>;
  34817. /**
  34818. * An event triggered when a texture is created
  34819. */
  34820. onNewTextureAddedObservable: Observable<BaseTexture>;
  34821. /**
  34822. * An event triggered when a texture is removed
  34823. */
  34824. onTextureRemovedObservable: Observable<BaseTexture>;
  34825. /**
  34826. * An event triggered when render targets are about to be rendered
  34827. * Can happen multiple times per frame.
  34828. */
  34829. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34830. /**
  34831. * An event triggered when render targets were rendered.
  34832. * Can happen multiple times per frame.
  34833. */
  34834. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34835. /**
  34836. * An event triggered before calculating deterministic simulation step
  34837. */
  34838. onBeforeStepObservable: Observable<Scene>;
  34839. /**
  34840. * An event triggered after calculating deterministic simulation step
  34841. */
  34842. onAfterStepObservable: Observable<Scene>;
  34843. /**
  34844. * An event triggered when the activeCamera property is updated
  34845. */
  34846. onActiveCameraChanged: Observable<Scene>;
  34847. /**
  34848. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34849. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34850. * 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)
  34851. */
  34852. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34853. /**
  34854. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34855. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34856. * 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)
  34857. */
  34858. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34859. /**
  34860. * This Observable will when a mesh has been imported into the scene.
  34861. */
  34862. onMeshImportedObservable: Observable<AbstractMesh>;
  34863. /**
  34864. * This Observable will when an animation file has been imported into the scene.
  34865. */
  34866. onAnimationFileImportedObservable: Observable<Scene>;
  34867. /**
  34868. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34869. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34870. */
  34871. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34872. /** @hidden */
  34873. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34874. /**
  34875. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34876. */
  34877. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34878. /**
  34879. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34880. */
  34881. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34882. /**
  34883. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34884. */
  34885. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34886. /** Callback called when a pointer move is detected */
  34887. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34888. /** Callback called when a pointer down is detected */
  34889. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34890. /** Callback called when a pointer up is detected */
  34891. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34892. /** Callback called when a pointer pick is detected */
  34893. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34894. /**
  34895. * 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).
  34896. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34897. */
  34898. onPrePointerObservable: Observable<PointerInfoPre>;
  34899. /**
  34900. * Observable event triggered each time an input event is received from the rendering canvas
  34901. */
  34902. onPointerObservable: Observable<PointerInfo>;
  34903. /**
  34904. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34905. */
  34906. readonly unTranslatedPointer: Vector2;
  34907. /**
  34908. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34909. */
  34910. static DragMovementThreshold: number;
  34911. /**
  34912. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34913. */
  34914. static LongPressDelay: number;
  34915. /**
  34916. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34917. */
  34918. static DoubleClickDelay: number;
  34919. /** If you need to check double click without raising a single click at first click, enable this flag */
  34920. static ExclusiveDoubleClickMode: boolean;
  34921. /** @hidden */
  34922. _mirroredCameraPosition: Nullable<Vector3>;
  34923. /**
  34924. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34925. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34926. */
  34927. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34928. /**
  34929. * Observable event triggered each time an keyboard event is received from the hosting window
  34930. */
  34931. onKeyboardObservable: Observable<KeyboardInfo>;
  34932. private _useRightHandedSystem;
  34933. /**
  34934. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34935. */
  34936. useRightHandedSystem: boolean;
  34937. private _timeAccumulator;
  34938. private _currentStepId;
  34939. private _currentInternalStep;
  34940. /**
  34941. * Sets the step Id used by deterministic lock step
  34942. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34943. * @param newStepId defines the step Id
  34944. */
  34945. setStepId(newStepId: number): void;
  34946. /**
  34947. * Gets the step Id used by deterministic lock step
  34948. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34949. * @returns the step Id
  34950. */
  34951. getStepId(): number;
  34952. /**
  34953. * Gets the internal step used by deterministic lock step
  34954. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34955. * @returns the internal step
  34956. */
  34957. getInternalStep(): number;
  34958. private _fogEnabled;
  34959. /**
  34960. * Gets or sets a boolean indicating if fog is enabled on this scene
  34961. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34962. * (Default is true)
  34963. */
  34964. fogEnabled: boolean;
  34965. private _fogMode;
  34966. /**
  34967. * Gets or sets the fog mode to use
  34968. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34969. * | mode | value |
  34970. * | --- | --- |
  34971. * | FOGMODE_NONE | 0 |
  34972. * | FOGMODE_EXP | 1 |
  34973. * | FOGMODE_EXP2 | 2 |
  34974. * | FOGMODE_LINEAR | 3 |
  34975. */
  34976. fogMode: number;
  34977. /**
  34978. * Gets or sets the fog color to use
  34979. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34980. * (Default is Color3(0.2, 0.2, 0.3))
  34981. */
  34982. fogColor: Color3;
  34983. /**
  34984. * Gets or sets the fog density to use
  34985. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34986. * (Default is 0.1)
  34987. */
  34988. fogDensity: number;
  34989. /**
  34990. * Gets or sets the fog start distance to use
  34991. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34992. * (Default is 0)
  34993. */
  34994. fogStart: number;
  34995. /**
  34996. * Gets or sets the fog end distance to use
  34997. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34998. * (Default is 1000)
  34999. */
  35000. fogEnd: number;
  35001. private _shadowsEnabled;
  35002. /**
  35003. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35004. */
  35005. shadowsEnabled: boolean;
  35006. private _lightsEnabled;
  35007. /**
  35008. * Gets or sets a boolean indicating if lights are enabled on this scene
  35009. */
  35010. lightsEnabled: boolean;
  35011. /** All of the active cameras added to this scene. */
  35012. activeCameras: Camera[];
  35013. /** @hidden */
  35014. _activeCamera: Nullable<Camera>;
  35015. /** Gets or sets the current active camera */
  35016. activeCamera: Nullable<Camera>;
  35017. private _defaultMaterial;
  35018. /** The default material used on meshes when no material is affected */
  35019. /** The default material used on meshes when no material is affected */
  35020. defaultMaterial: Material;
  35021. private _texturesEnabled;
  35022. /**
  35023. * Gets or sets a boolean indicating if textures are enabled on this scene
  35024. */
  35025. texturesEnabled: boolean;
  35026. /**
  35027. * Gets or sets a boolean indicating if particles are enabled on this scene
  35028. */
  35029. particlesEnabled: boolean;
  35030. /**
  35031. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35032. */
  35033. spritesEnabled: boolean;
  35034. private _skeletonsEnabled;
  35035. /**
  35036. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35037. */
  35038. skeletonsEnabled: boolean;
  35039. /**
  35040. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35041. */
  35042. lensFlaresEnabled: boolean;
  35043. /**
  35044. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35045. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35046. */
  35047. collisionsEnabled: boolean;
  35048. private _collisionCoordinator;
  35049. /** @hidden */
  35050. readonly collisionCoordinator: ICollisionCoordinator;
  35051. /**
  35052. * Defines the gravity applied to this scene (used only for collisions)
  35053. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35054. */
  35055. gravity: Vector3;
  35056. /**
  35057. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35058. */
  35059. postProcessesEnabled: boolean;
  35060. /**
  35061. * The list of postprocesses added to the scene
  35062. */
  35063. postProcesses: PostProcess[];
  35064. /**
  35065. * Gets the current postprocess manager
  35066. */
  35067. postProcessManager: PostProcessManager;
  35068. /**
  35069. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35070. */
  35071. renderTargetsEnabled: boolean;
  35072. /**
  35073. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35074. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35075. */
  35076. dumpNextRenderTargets: boolean;
  35077. /**
  35078. * The list of user defined render targets added to the scene
  35079. */
  35080. customRenderTargets: RenderTargetTexture[];
  35081. /**
  35082. * Defines if texture loading must be delayed
  35083. * If true, textures will only be loaded when they need to be rendered
  35084. */
  35085. useDelayedTextureLoading: boolean;
  35086. /**
  35087. * Gets the list of meshes imported to the scene through SceneLoader
  35088. */
  35089. importedMeshesFiles: String[];
  35090. /**
  35091. * Gets or sets a boolean indicating if probes are enabled on this scene
  35092. */
  35093. probesEnabled: boolean;
  35094. /**
  35095. * Gets or sets the current offline provider to use to store scene data
  35096. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35097. */
  35098. offlineProvider: IOfflineProvider;
  35099. /**
  35100. * Gets or sets the action manager associated with the scene
  35101. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35102. */
  35103. actionManager: AbstractActionManager;
  35104. private _meshesForIntersections;
  35105. /**
  35106. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35107. */
  35108. proceduralTexturesEnabled: boolean;
  35109. private _engine;
  35110. private _totalVertices;
  35111. /** @hidden */
  35112. _activeIndices: PerfCounter;
  35113. /** @hidden */
  35114. _activeParticles: PerfCounter;
  35115. /** @hidden */
  35116. _activeBones: PerfCounter;
  35117. private _animationRatio;
  35118. /** @hidden */
  35119. _animationTimeLast: number;
  35120. /** @hidden */
  35121. _animationTime: number;
  35122. /**
  35123. * Gets or sets a general scale for animation speed
  35124. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35125. */
  35126. animationTimeScale: number;
  35127. /** @hidden */
  35128. _cachedMaterial: Nullable<Material>;
  35129. /** @hidden */
  35130. _cachedEffect: Nullable<Effect>;
  35131. /** @hidden */
  35132. _cachedVisibility: Nullable<number>;
  35133. private _renderId;
  35134. private _frameId;
  35135. private _executeWhenReadyTimeoutId;
  35136. private _intermediateRendering;
  35137. private _viewUpdateFlag;
  35138. private _projectionUpdateFlag;
  35139. /** @hidden */
  35140. _toBeDisposed: Nullable<IDisposable>[];
  35141. private _activeRequests;
  35142. /** @hidden */
  35143. _pendingData: any[];
  35144. private _isDisposed;
  35145. /**
  35146. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35147. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35148. */
  35149. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35150. private _activeMeshes;
  35151. private _processedMaterials;
  35152. private _renderTargets;
  35153. /** @hidden */
  35154. _activeParticleSystems: SmartArray<IParticleSystem>;
  35155. private _activeSkeletons;
  35156. private _softwareSkinnedMeshes;
  35157. private _renderingManager;
  35158. /** @hidden */
  35159. _activeAnimatables: Animatable[];
  35160. private _transformMatrix;
  35161. private _sceneUbo;
  35162. /** @hidden */
  35163. _viewMatrix: Matrix;
  35164. private _projectionMatrix;
  35165. /** @hidden */
  35166. _forcedViewPosition: Nullable<Vector3>;
  35167. /** @hidden */
  35168. _frustumPlanes: Plane[];
  35169. /**
  35170. * Gets the list of frustum planes (built from the active camera)
  35171. */
  35172. readonly frustumPlanes: Plane[];
  35173. /**
  35174. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35175. * This is useful if there are more lights that the maximum simulteanous authorized
  35176. */
  35177. requireLightSorting: boolean;
  35178. /** @hidden */
  35179. readonly useMaterialMeshMap: boolean;
  35180. /** @hidden */
  35181. readonly useClonedMeshhMap: boolean;
  35182. private _externalData;
  35183. private _uid;
  35184. /**
  35185. * @hidden
  35186. * Backing store of defined scene components.
  35187. */
  35188. _components: ISceneComponent[];
  35189. /**
  35190. * @hidden
  35191. * Backing store of defined scene components.
  35192. */
  35193. _serializableComponents: ISceneSerializableComponent[];
  35194. /**
  35195. * List of components to register on the next registration step.
  35196. */
  35197. private _transientComponents;
  35198. /**
  35199. * Registers the transient components if needed.
  35200. */
  35201. private _registerTransientComponents;
  35202. /**
  35203. * @hidden
  35204. * Add a component to the scene.
  35205. * Note that the ccomponent could be registered on th next frame if this is called after
  35206. * the register component stage.
  35207. * @param component Defines the component to add to the scene
  35208. */
  35209. _addComponent(component: ISceneComponent): void;
  35210. /**
  35211. * @hidden
  35212. * Gets a component from the scene.
  35213. * @param name defines the name of the component to retrieve
  35214. * @returns the component or null if not present
  35215. */
  35216. _getComponent(name: string): Nullable<ISceneComponent>;
  35217. /**
  35218. * @hidden
  35219. * Defines the actions happening before camera updates.
  35220. */
  35221. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35222. /**
  35223. * @hidden
  35224. * Defines the actions happening before clear the canvas.
  35225. */
  35226. _beforeClearStage: Stage<SimpleStageAction>;
  35227. /**
  35228. * @hidden
  35229. * Defines the actions when collecting render targets for the frame.
  35230. */
  35231. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35232. /**
  35233. * @hidden
  35234. * Defines the actions happening for one camera in the frame.
  35235. */
  35236. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35237. /**
  35238. * @hidden
  35239. * Defines the actions happening during the per mesh ready checks.
  35240. */
  35241. _isReadyForMeshStage: Stage<MeshStageAction>;
  35242. /**
  35243. * @hidden
  35244. * Defines the actions happening before evaluate active mesh checks.
  35245. */
  35246. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35247. /**
  35248. * @hidden
  35249. * Defines the actions happening during the evaluate sub mesh checks.
  35250. */
  35251. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35252. /**
  35253. * @hidden
  35254. * Defines the actions happening during the active mesh stage.
  35255. */
  35256. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35257. /**
  35258. * @hidden
  35259. * Defines the actions happening during the per camera render target step.
  35260. */
  35261. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35262. /**
  35263. * @hidden
  35264. * Defines the actions happening just before the active camera is drawing.
  35265. */
  35266. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35267. /**
  35268. * @hidden
  35269. * Defines the actions happening just before a render target is drawing.
  35270. */
  35271. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35272. /**
  35273. * @hidden
  35274. * Defines the actions happening just before a rendering group is drawing.
  35275. */
  35276. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35277. /**
  35278. * @hidden
  35279. * Defines the actions happening just before a mesh is drawing.
  35280. */
  35281. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35282. /**
  35283. * @hidden
  35284. * Defines the actions happening just after a mesh has been drawn.
  35285. */
  35286. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35287. /**
  35288. * @hidden
  35289. * Defines the actions happening just after a rendering group has been drawn.
  35290. */
  35291. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35292. /**
  35293. * @hidden
  35294. * Defines the actions happening just after the active camera has been drawn.
  35295. */
  35296. _afterCameraDrawStage: Stage<CameraStageAction>;
  35297. /**
  35298. * @hidden
  35299. * Defines the actions happening just after a render target has been drawn.
  35300. */
  35301. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35302. /**
  35303. * @hidden
  35304. * Defines the actions happening just after rendering all cameras and computing intersections.
  35305. */
  35306. _afterRenderStage: Stage<SimpleStageAction>;
  35307. /**
  35308. * @hidden
  35309. * Defines the actions happening when a pointer move event happens.
  35310. */
  35311. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35312. /**
  35313. * @hidden
  35314. * Defines the actions happening when a pointer down event happens.
  35315. */
  35316. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35317. /**
  35318. * @hidden
  35319. * Defines the actions happening when a pointer up event happens.
  35320. */
  35321. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35322. /**
  35323. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35324. */
  35325. private geometriesByUniqueId;
  35326. /**
  35327. * Creates a new Scene
  35328. * @param engine defines the engine to use to render this scene
  35329. * @param options defines the scene options
  35330. */
  35331. constructor(engine: Engine, options?: SceneOptions);
  35332. /**
  35333. * Gets a string idenfifying the name of the class
  35334. * @returns "Scene" string
  35335. */
  35336. getClassName(): string;
  35337. private _defaultMeshCandidates;
  35338. /**
  35339. * @hidden
  35340. */
  35341. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35342. private _defaultSubMeshCandidates;
  35343. /**
  35344. * @hidden
  35345. */
  35346. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35347. /**
  35348. * Sets the default candidate providers for the scene.
  35349. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35350. * and getCollidingSubMeshCandidates to their default function
  35351. */
  35352. setDefaultCandidateProviders(): void;
  35353. /**
  35354. * Gets the mesh that is currently under the pointer
  35355. */
  35356. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35357. /**
  35358. * Gets or sets the current on-screen X position of the pointer
  35359. */
  35360. pointerX: number;
  35361. /**
  35362. * Gets or sets the current on-screen Y position of the pointer
  35363. */
  35364. pointerY: number;
  35365. /**
  35366. * Gets the cached material (ie. the latest rendered one)
  35367. * @returns the cached material
  35368. */
  35369. getCachedMaterial(): Nullable<Material>;
  35370. /**
  35371. * Gets the cached effect (ie. the latest rendered one)
  35372. * @returns the cached effect
  35373. */
  35374. getCachedEffect(): Nullable<Effect>;
  35375. /**
  35376. * Gets the cached visibility state (ie. the latest rendered one)
  35377. * @returns the cached visibility state
  35378. */
  35379. getCachedVisibility(): Nullable<number>;
  35380. /**
  35381. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35382. * @param material defines the current material
  35383. * @param effect defines the current effect
  35384. * @param visibility defines the current visibility state
  35385. * @returns true if one parameter is not cached
  35386. */
  35387. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35388. /**
  35389. * Gets the engine associated with the scene
  35390. * @returns an Engine
  35391. */
  35392. getEngine(): Engine;
  35393. /**
  35394. * Gets the total number of vertices rendered per frame
  35395. * @returns the total number of vertices rendered per frame
  35396. */
  35397. getTotalVertices(): number;
  35398. /**
  35399. * Gets the performance counter for total vertices
  35400. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35401. */
  35402. readonly totalVerticesPerfCounter: PerfCounter;
  35403. /**
  35404. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35405. * @returns the total number of active indices rendered per frame
  35406. */
  35407. getActiveIndices(): number;
  35408. /**
  35409. * Gets the performance counter for active indices
  35410. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35411. */
  35412. readonly totalActiveIndicesPerfCounter: PerfCounter;
  35413. /**
  35414. * Gets the total number of active particles rendered per frame
  35415. * @returns the total number of active particles rendered per frame
  35416. */
  35417. getActiveParticles(): number;
  35418. /**
  35419. * Gets the performance counter for active particles
  35420. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35421. */
  35422. readonly activeParticlesPerfCounter: PerfCounter;
  35423. /**
  35424. * Gets the total number of active bones rendered per frame
  35425. * @returns the total number of active bones rendered per frame
  35426. */
  35427. getActiveBones(): number;
  35428. /**
  35429. * Gets the performance counter for active bones
  35430. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35431. */
  35432. readonly activeBonesPerfCounter: PerfCounter;
  35433. /**
  35434. * Gets the array of active meshes
  35435. * @returns an array of AbstractMesh
  35436. */
  35437. getActiveMeshes(): SmartArray<AbstractMesh>;
  35438. /**
  35439. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35440. * @returns a number
  35441. */
  35442. getAnimationRatio(): number;
  35443. /**
  35444. * Gets an unique Id for the current render phase
  35445. * @returns a number
  35446. */
  35447. getRenderId(): number;
  35448. /**
  35449. * Gets an unique Id for the current frame
  35450. * @returns a number
  35451. */
  35452. getFrameId(): number;
  35453. /** Call this function if you want to manually increment the render Id*/
  35454. incrementRenderId(): void;
  35455. private _createUbo;
  35456. /**
  35457. * Use this method to simulate a pointer move on a mesh
  35458. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35459. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35460. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35461. * @returns the current scene
  35462. */
  35463. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35464. /**
  35465. * Use this method to simulate a pointer down on a mesh
  35466. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35467. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35468. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35469. * @returns the current scene
  35470. */
  35471. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35472. /**
  35473. * Use this method to simulate a pointer up on a mesh
  35474. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35475. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35476. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35477. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35478. * @returns the current scene
  35479. */
  35480. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35481. /**
  35482. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35483. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35484. * @returns true if the pointer was captured
  35485. */
  35486. isPointerCaptured(pointerId?: number): boolean;
  35487. /**
  35488. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35489. * @param attachUp defines if you want to attach events to pointerup
  35490. * @param attachDown defines if you want to attach events to pointerdown
  35491. * @param attachMove defines if you want to attach events to pointermove
  35492. */
  35493. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35494. /** Detaches all event handlers*/
  35495. detachControl(): void;
  35496. /**
  35497. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35498. * Delay loaded resources are not taking in account
  35499. * @return true if all required resources are ready
  35500. */
  35501. isReady(): boolean;
  35502. /** Resets all cached information relative to material (including effect and visibility) */
  35503. resetCachedMaterial(): void;
  35504. /**
  35505. * Registers a function to be called before every frame render
  35506. * @param func defines the function to register
  35507. */
  35508. registerBeforeRender(func: () => void): void;
  35509. /**
  35510. * Unregisters a function called before every frame render
  35511. * @param func defines the function to unregister
  35512. */
  35513. unregisterBeforeRender(func: () => void): void;
  35514. /**
  35515. * Registers a function to be called after every frame render
  35516. * @param func defines the function to register
  35517. */
  35518. registerAfterRender(func: () => void): void;
  35519. /**
  35520. * Unregisters a function called after every frame render
  35521. * @param func defines the function to unregister
  35522. */
  35523. unregisterAfterRender(func: () => void): void;
  35524. private _executeOnceBeforeRender;
  35525. /**
  35526. * The provided function will run before render once and will be disposed afterwards.
  35527. * A timeout delay can be provided so that the function will be executed in N ms.
  35528. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35529. * @param func The function to be executed.
  35530. * @param timeout optional delay in ms
  35531. */
  35532. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35533. /** @hidden */
  35534. _addPendingData(data: any): void;
  35535. /** @hidden */
  35536. _removePendingData(data: any): void;
  35537. /**
  35538. * Returns the number of items waiting to be loaded
  35539. * @returns the number of items waiting to be loaded
  35540. */
  35541. getWaitingItemsCount(): number;
  35542. /**
  35543. * Returns a boolean indicating if the scene is still loading data
  35544. */
  35545. readonly isLoading: boolean;
  35546. /**
  35547. * Registers a function to be executed when the scene is ready
  35548. * @param {Function} func - the function to be executed
  35549. */
  35550. executeWhenReady(func: () => void): void;
  35551. /**
  35552. * Returns a promise that resolves when the scene is ready
  35553. * @returns A promise that resolves when the scene is ready
  35554. */
  35555. whenReadyAsync(): Promise<void>;
  35556. /** @hidden */
  35557. _checkIsReady(): void;
  35558. /**
  35559. * Gets all animatable attached to the scene
  35560. */
  35561. readonly animatables: Animatable[];
  35562. /**
  35563. * Resets the last animation time frame.
  35564. * Useful to override when animations start running when loading a scene for the first time.
  35565. */
  35566. resetLastAnimationTimeFrame(): void;
  35567. /**
  35568. * Gets the current view matrix
  35569. * @returns a Matrix
  35570. */
  35571. getViewMatrix(): Matrix;
  35572. /**
  35573. * Gets the current projection matrix
  35574. * @returns a Matrix
  35575. */
  35576. getProjectionMatrix(): Matrix;
  35577. /**
  35578. * Gets the current transform matrix
  35579. * @returns a Matrix made of View * Projection
  35580. */
  35581. getTransformMatrix(): Matrix;
  35582. /**
  35583. * Sets the current transform matrix
  35584. * @param viewL defines the View matrix to use
  35585. * @param projectionL defines the Projection matrix to use
  35586. * @param viewR defines the right View matrix to use (if provided)
  35587. * @param projectionR defines the right Projection matrix to use (if provided)
  35588. */
  35589. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35590. /**
  35591. * Gets the uniform buffer used to store scene data
  35592. * @returns a UniformBuffer
  35593. */
  35594. getSceneUniformBuffer(): UniformBuffer;
  35595. /**
  35596. * Gets an unique (relatively to the current scene) Id
  35597. * @returns an unique number for the scene
  35598. */
  35599. getUniqueId(): number;
  35600. /**
  35601. * Add a mesh to the list of scene's meshes
  35602. * @param newMesh defines the mesh to add
  35603. * @param recursive if all child meshes should also be added to the scene
  35604. */
  35605. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35606. /**
  35607. * Remove a mesh for the list of scene's meshes
  35608. * @param toRemove defines the mesh to remove
  35609. * @param recursive if all child meshes should also be removed from the scene
  35610. * @returns the index where the mesh was in the mesh list
  35611. */
  35612. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35613. /**
  35614. * Add a transform node to the list of scene's transform nodes
  35615. * @param newTransformNode defines the transform node to add
  35616. */
  35617. addTransformNode(newTransformNode: TransformNode): void;
  35618. /**
  35619. * Remove a transform node for the list of scene's transform nodes
  35620. * @param toRemove defines the transform node to remove
  35621. * @returns the index where the transform node was in the transform node list
  35622. */
  35623. removeTransformNode(toRemove: TransformNode): number;
  35624. /**
  35625. * Remove a skeleton for the list of scene's skeletons
  35626. * @param toRemove defines the skeleton to remove
  35627. * @returns the index where the skeleton was in the skeleton list
  35628. */
  35629. removeSkeleton(toRemove: Skeleton): number;
  35630. /**
  35631. * Remove a morph target for the list of scene's morph targets
  35632. * @param toRemove defines the morph target to remove
  35633. * @returns the index where the morph target was in the morph target list
  35634. */
  35635. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35636. /**
  35637. * Remove a light for the list of scene's lights
  35638. * @param toRemove defines the light to remove
  35639. * @returns the index where the light was in the light list
  35640. */
  35641. removeLight(toRemove: Light): number;
  35642. /**
  35643. * Remove a camera for the list of scene's cameras
  35644. * @param toRemove defines the camera to remove
  35645. * @returns the index where the camera was in the camera list
  35646. */
  35647. removeCamera(toRemove: Camera): number;
  35648. /**
  35649. * Remove a particle system for the list of scene's particle systems
  35650. * @param toRemove defines the particle system to remove
  35651. * @returns the index where the particle system was in the particle system list
  35652. */
  35653. removeParticleSystem(toRemove: IParticleSystem): number;
  35654. /**
  35655. * Remove a animation for the list of scene's animations
  35656. * @param toRemove defines the animation to remove
  35657. * @returns the index where the animation was in the animation list
  35658. */
  35659. removeAnimation(toRemove: Animation): number;
  35660. /**
  35661. * Will stop the animation of the given target
  35662. * @param target - the target
  35663. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35664. * @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)
  35665. */
  35666. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35667. /**
  35668. * Removes the given animation group from this scene.
  35669. * @param toRemove The animation group to remove
  35670. * @returns The index of the removed animation group
  35671. */
  35672. removeAnimationGroup(toRemove: AnimationGroup): number;
  35673. /**
  35674. * Removes the given multi-material from this scene.
  35675. * @param toRemove The multi-material to remove
  35676. * @returns The index of the removed multi-material
  35677. */
  35678. removeMultiMaterial(toRemove: MultiMaterial): number;
  35679. /**
  35680. * Removes the given material from this scene.
  35681. * @param toRemove The material to remove
  35682. * @returns The index of the removed material
  35683. */
  35684. removeMaterial(toRemove: Material): number;
  35685. /**
  35686. * Removes the given action manager from this scene.
  35687. * @param toRemove The action manager to remove
  35688. * @returns The index of the removed action manager
  35689. */
  35690. removeActionManager(toRemove: AbstractActionManager): number;
  35691. /**
  35692. * Removes the given texture from this scene.
  35693. * @param toRemove The texture to remove
  35694. * @returns The index of the removed texture
  35695. */
  35696. removeTexture(toRemove: BaseTexture): number;
  35697. /**
  35698. * Adds the given light to this scene
  35699. * @param newLight The light to add
  35700. */
  35701. addLight(newLight: Light): void;
  35702. /**
  35703. * Sorts the list list based on light priorities
  35704. */
  35705. sortLightsByPriority(): void;
  35706. /**
  35707. * Adds the given camera to this scene
  35708. * @param newCamera The camera to add
  35709. */
  35710. addCamera(newCamera: Camera): void;
  35711. /**
  35712. * Adds the given skeleton to this scene
  35713. * @param newSkeleton The skeleton to add
  35714. */
  35715. addSkeleton(newSkeleton: Skeleton): void;
  35716. /**
  35717. * Adds the given particle system to this scene
  35718. * @param newParticleSystem The particle system to add
  35719. */
  35720. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35721. /**
  35722. * Adds the given animation to this scene
  35723. * @param newAnimation The animation to add
  35724. */
  35725. addAnimation(newAnimation: Animation): void;
  35726. /**
  35727. * Adds the given animation group to this scene.
  35728. * @param newAnimationGroup The animation group to add
  35729. */
  35730. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35731. /**
  35732. * Adds the given multi-material to this scene
  35733. * @param newMultiMaterial The multi-material to add
  35734. */
  35735. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35736. /**
  35737. * Adds the given material to this scene
  35738. * @param newMaterial The material to add
  35739. */
  35740. addMaterial(newMaterial: Material): void;
  35741. /**
  35742. * Adds the given morph target to this scene
  35743. * @param newMorphTargetManager The morph target to add
  35744. */
  35745. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35746. /**
  35747. * Adds the given geometry to this scene
  35748. * @param newGeometry The geometry to add
  35749. */
  35750. addGeometry(newGeometry: Geometry): void;
  35751. /**
  35752. * Adds the given action manager to this scene
  35753. * @param newActionManager The action manager to add
  35754. */
  35755. addActionManager(newActionManager: AbstractActionManager): void;
  35756. /**
  35757. * Adds the given texture to this scene.
  35758. * @param newTexture The texture to add
  35759. */
  35760. addTexture(newTexture: BaseTexture): void;
  35761. /**
  35762. * Switch active camera
  35763. * @param newCamera defines the new active camera
  35764. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35765. */
  35766. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35767. /**
  35768. * sets the active camera of the scene using its ID
  35769. * @param id defines the camera's ID
  35770. * @return the new active camera or null if none found.
  35771. */
  35772. setActiveCameraByID(id: string): Nullable<Camera>;
  35773. /**
  35774. * sets the active camera of the scene using its name
  35775. * @param name defines the camera's name
  35776. * @returns the new active camera or null if none found.
  35777. */
  35778. setActiveCameraByName(name: string): Nullable<Camera>;
  35779. /**
  35780. * get an animation group using its name
  35781. * @param name defines the material's name
  35782. * @return the animation group or null if none found.
  35783. */
  35784. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35785. /**
  35786. * Get a material using its unique id
  35787. * @param uniqueId defines the material's unique id
  35788. * @return the material or null if none found.
  35789. */
  35790. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35791. /**
  35792. * get a material using its id
  35793. * @param id defines the material's ID
  35794. * @return the material or null if none found.
  35795. */
  35796. getMaterialByID(id: string): Nullable<Material>;
  35797. /**
  35798. * Gets a the last added material using a given id
  35799. * @param id defines the material's ID
  35800. * @return the last material with the given id or null if none found.
  35801. */
  35802. getLastMaterialByID(id: string): Nullable<Material>;
  35803. /**
  35804. * Gets a material using its name
  35805. * @param name defines the material's name
  35806. * @return the material or null if none found.
  35807. */
  35808. getMaterialByName(name: string): Nullable<Material>;
  35809. /**
  35810. * Get a texture using its unique id
  35811. * @param uniqueId defines the texture's unique id
  35812. * @return the texture or null if none found.
  35813. */
  35814. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35815. /**
  35816. * Gets a camera using its id
  35817. * @param id defines the id to look for
  35818. * @returns the camera or null if not found
  35819. */
  35820. getCameraByID(id: string): Nullable<Camera>;
  35821. /**
  35822. * Gets a camera using its unique id
  35823. * @param uniqueId defines the unique id to look for
  35824. * @returns the camera or null if not found
  35825. */
  35826. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35827. /**
  35828. * Gets a camera using its name
  35829. * @param name defines the camera's name
  35830. * @return the camera or null if none found.
  35831. */
  35832. getCameraByName(name: string): Nullable<Camera>;
  35833. /**
  35834. * Gets a bone using its id
  35835. * @param id defines the bone's id
  35836. * @return the bone or null if not found
  35837. */
  35838. getBoneByID(id: string): Nullable<Bone>;
  35839. /**
  35840. * Gets a bone using its id
  35841. * @param name defines the bone's name
  35842. * @return the bone or null if not found
  35843. */
  35844. getBoneByName(name: string): Nullable<Bone>;
  35845. /**
  35846. * Gets a light node using its name
  35847. * @param name defines the the light's name
  35848. * @return the light or null if none found.
  35849. */
  35850. getLightByName(name: string): Nullable<Light>;
  35851. /**
  35852. * Gets a light node using its id
  35853. * @param id defines the light's id
  35854. * @return the light or null if none found.
  35855. */
  35856. getLightByID(id: string): Nullable<Light>;
  35857. /**
  35858. * Gets a light node using its scene-generated unique ID
  35859. * @param uniqueId defines the light's unique id
  35860. * @return the light or null if none found.
  35861. */
  35862. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35863. /**
  35864. * Gets a particle system by id
  35865. * @param id defines the particle system id
  35866. * @return the corresponding system or null if none found
  35867. */
  35868. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35869. /**
  35870. * Gets a geometry using its ID
  35871. * @param id defines the geometry's id
  35872. * @return the geometry or null if none found.
  35873. */
  35874. getGeometryByID(id: string): Nullable<Geometry>;
  35875. private _getGeometryByUniqueID;
  35876. /**
  35877. * Add a new geometry to this scene
  35878. * @param geometry defines the geometry to be added to the scene.
  35879. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35880. * @return a boolean defining if the geometry was added or not
  35881. */
  35882. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35883. /**
  35884. * Removes an existing geometry
  35885. * @param geometry defines the geometry to be removed from the scene
  35886. * @return a boolean defining if the geometry was removed or not
  35887. */
  35888. removeGeometry(geometry: Geometry): boolean;
  35889. /**
  35890. * Gets the list of geometries attached to the scene
  35891. * @returns an array of Geometry
  35892. */
  35893. getGeometries(): Geometry[];
  35894. /**
  35895. * Gets the first added mesh found of a given ID
  35896. * @param id defines the id to search for
  35897. * @return the mesh found or null if not found at all
  35898. */
  35899. getMeshByID(id: string): Nullable<AbstractMesh>;
  35900. /**
  35901. * Gets a list of meshes using their id
  35902. * @param id defines the id to search for
  35903. * @returns a list of meshes
  35904. */
  35905. getMeshesByID(id: string): Array<AbstractMesh>;
  35906. /**
  35907. * Gets the first added transform node found of a given ID
  35908. * @param id defines the id to search for
  35909. * @return the found transform node or null if not found at all.
  35910. */
  35911. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35912. /**
  35913. * Gets a transform node with its auto-generated unique id
  35914. * @param uniqueId efines the unique id to search for
  35915. * @return the found transform node or null if not found at all.
  35916. */
  35917. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35918. /**
  35919. * Gets a list of transform nodes using their id
  35920. * @param id defines the id to search for
  35921. * @returns a list of transform nodes
  35922. */
  35923. getTransformNodesByID(id: string): Array<TransformNode>;
  35924. /**
  35925. * Gets a mesh with its auto-generated unique id
  35926. * @param uniqueId defines the unique id to search for
  35927. * @return the found mesh or null if not found at all.
  35928. */
  35929. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35930. /**
  35931. * Gets a the last added mesh using a given id
  35932. * @param id defines the id to search for
  35933. * @return the found mesh or null if not found at all.
  35934. */
  35935. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35936. /**
  35937. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35938. * @param id defines the id to search for
  35939. * @return the found node or null if not found at all
  35940. */
  35941. getLastEntryByID(id: string): Nullable<Node>;
  35942. /**
  35943. * Gets a node (Mesh, Camera, Light) using a given id
  35944. * @param id defines the id to search for
  35945. * @return the found node or null if not found at all
  35946. */
  35947. getNodeByID(id: string): Nullable<Node>;
  35948. /**
  35949. * Gets a node (Mesh, Camera, Light) using a given name
  35950. * @param name defines the name to search for
  35951. * @return the found node or null if not found at all.
  35952. */
  35953. getNodeByName(name: string): Nullable<Node>;
  35954. /**
  35955. * Gets a mesh using a given name
  35956. * @param name defines the name to search for
  35957. * @return the found mesh or null if not found at all.
  35958. */
  35959. getMeshByName(name: string): Nullable<AbstractMesh>;
  35960. /**
  35961. * Gets a transform node using a given name
  35962. * @param name defines the name to search for
  35963. * @return the found transform node or null if not found at all.
  35964. */
  35965. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35966. /**
  35967. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35968. * @param id defines the id to search for
  35969. * @return the found skeleton or null if not found at all.
  35970. */
  35971. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35972. /**
  35973. * Gets a skeleton using a given auto generated unique id
  35974. * @param uniqueId defines the unique id to search for
  35975. * @return the found skeleton or null if not found at all.
  35976. */
  35977. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35978. /**
  35979. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35980. * @param id defines the id to search for
  35981. * @return the found skeleton or null if not found at all.
  35982. */
  35983. getSkeletonById(id: string): Nullable<Skeleton>;
  35984. /**
  35985. * Gets a skeleton using a given name
  35986. * @param name defines the name to search for
  35987. * @return the found skeleton or null if not found at all.
  35988. */
  35989. getSkeletonByName(name: string): Nullable<Skeleton>;
  35990. /**
  35991. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35992. * @param id defines the id to search for
  35993. * @return the found morph target manager or null if not found at all.
  35994. */
  35995. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35996. /**
  35997. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35998. * @param id defines the id to search for
  35999. * @return the found morph target or null if not found at all.
  36000. */
  36001. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36002. /**
  36003. * Gets a boolean indicating if the given mesh is active
  36004. * @param mesh defines the mesh to look for
  36005. * @returns true if the mesh is in the active list
  36006. */
  36007. isActiveMesh(mesh: AbstractMesh): boolean;
  36008. /**
  36009. * Return a unique id as a string which can serve as an identifier for the scene
  36010. */
  36011. readonly uid: string;
  36012. /**
  36013. * Add an externaly attached data from its key.
  36014. * This method call will fail and return false, if such key already exists.
  36015. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36016. * @param key the unique key that identifies the data
  36017. * @param data the data object to associate to the key for this Engine instance
  36018. * @return true if no such key were already present and the data was added successfully, false otherwise
  36019. */
  36020. addExternalData<T>(key: string, data: T): boolean;
  36021. /**
  36022. * Get an externaly attached data from its key
  36023. * @param key the unique key that identifies the data
  36024. * @return the associated data, if present (can be null), or undefined if not present
  36025. */
  36026. getExternalData<T>(key: string): Nullable<T>;
  36027. /**
  36028. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36029. * @param key the unique key that identifies the data
  36030. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36031. * @return the associated data, can be null if the factory returned null.
  36032. */
  36033. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36034. /**
  36035. * Remove an externaly attached data from the Engine instance
  36036. * @param key the unique key that identifies the data
  36037. * @return true if the data was successfully removed, false if it doesn't exist
  36038. */
  36039. removeExternalData(key: string): boolean;
  36040. private _evaluateSubMesh;
  36041. /**
  36042. * Clear the processed materials smart array preventing retention point in material dispose.
  36043. */
  36044. freeProcessedMaterials(): void;
  36045. private _preventFreeActiveMeshesAndRenderingGroups;
  36046. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36047. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36048. * when disposing several meshes in a row or a hierarchy of meshes.
  36049. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36050. */
  36051. blockfreeActiveMeshesAndRenderingGroups: boolean;
  36052. /**
  36053. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36054. */
  36055. freeActiveMeshes(): void;
  36056. /**
  36057. * Clear the info related to rendering groups preventing retention points during dispose.
  36058. */
  36059. freeRenderingGroups(): void;
  36060. /** @hidden */
  36061. _isInIntermediateRendering(): boolean;
  36062. /**
  36063. * Lambda returning the list of potentially active meshes.
  36064. */
  36065. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36066. /**
  36067. * Lambda returning the list of potentially active sub meshes.
  36068. */
  36069. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36070. /**
  36071. * Lambda returning the list of potentially intersecting sub meshes.
  36072. */
  36073. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36074. /**
  36075. * Lambda returning the list of potentially colliding sub meshes.
  36076. */
  36077. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36078. private _activeMeshesFrozen;
  36079. private _skipEvaluateActiveMeshesCompletely;
  36080. /**
  36081. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36082. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36083. * @returns the current scene
  36084. */
  36085. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36086. /**
  36087. * Use this function to restart evaluating active meshes on every frame
  36088. * @returns the current scene
  36089. */
  36090. unfreezeActiveMeshes(): Scene;
  36091. private _evaluateActiveMeshes;
  36092. private _activeMesh;
  36093. /**
  36094. * Update the transform matrix to update from the current active camera
  36095. * @param force defines a boolean used to force the update even if cache is up to date
  36096. */
  36097. updateTransformMatrix(force?: boolean): void;
  36098. private _bindFrameBuffer;
  36099. /** @hidden */
  36100. _allowPostProcessClearColor: boolean;
  36101. /** @hidden */
  36102. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36103. private _processSubCameras;
  36104. private _checkIntersections;
  36105. /** @hidden */
  36106. _advancePhysicsEngineStep(step: number): void;
  36107. /**
  36108. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36109. */
  36110. getDeterministicFrameTime: () => number;
  36111. /** @hidden */
  36112. _animate(): void;
  36113. /** Execute all animations (for a frame) */
  36114. animate(): void;
  36115. /**
  36116. * Render the scene
  36117. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36118. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36119. */
  36120. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36121. /**
  36122. * Freeze all materials
  36123. * A frozen material will not be updatable but should be faster to render
  36124. */
  36125. freezeMaterials(): void;
  36126. /**
  36127. * Unfreeze all materials
  36128. * A frozen material will not be updatable but should be faster to render
  36129. */
  36130. unfreezeMaterials(): void;
  36131. /**
  36132. * Releases all held ressources
  36133. */
  36134. dispose(): void;
  36135. /**
  36136. * Gets if the scene is already disposed
  36137. */
  36138. readonly isDisposed: boolean;
  36139. /**
  36140. * Call this function to reduce memory footprint of the scene.
  36141. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36142. */
  36143. clearCachedVertexData(): void;
  36144. /**
  36145. * This function will remove the local cached buffer data from texture.
  36146. * It will save memory but will prevent the texture from being rebuilt
  36147. */
  36148. cleanCachedTextureBuffer(): void;
  36149. /**
  36150. * Get the world extend vectors with an optional filter
  36151. *
  36152. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36153. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36154. */
  36155. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36156. min: Vector3;
  36157. max: Vector3;
  36158. };
  36159. /**
  36160. * Creates a ray that can be used to pick in the scene
  36161. * @param x defines the x coordinate of the origin (on-screen)
  36162. * @param y defines the y coordinate of the origin (on-screen)
  36163. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36164. * @param camera defines the camera to use for the picking
  36165. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36166. * @returns a Ray
  36167. */
  36168. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36169. /**
  36170. * Creates a ray that can be used to pick in the scene
  36171. * @param x defines the x coordinate of the origin (on-screen)
  36172. * @param y defines the y coordinate of the origin (on-screen)
  36173. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36174. * @param result defines the ray where to store the picking ray
  36175. * @param camera defines the camera to use for the picking
  36176. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36177. * @returns the current scene
  36178. */
  36179. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36180. /**
  36181. * Creates a ray that can be used to pick in the scene
  36182. * @param x defines the x coordinate of the origin (on-screen)
  36183. * @param y defines the y coordinate of the origin (on-screen)
  36184. * @param camera defines the camera to use for the picking
  36185. * @returns a Ray
  36186. */
  36187. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36188. /**
  36189. * Creates a ray that can be used to pick in the scene
  36190. * @param x defines the x coordinate of the origin (on-screen)
  36191. * @param y defines the y coordinate of the origin (on-screen)
  36192. * @param result defines the ray where to store the picking ray
  36193. * @param camera defines the camera to use for the picking
  36194. * @returns the current scene
  36195. */
  36196. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36197. /** Launch a ray to try to pick a mesh in the scene
  36198. * @param x position on screen
  36199. * @param y position on screen
  36200. * @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
  36201. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36202. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36203. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36204. * @returns a PickingInfo
  36205. */
  36206. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36207. /** Use the given ray to pick a mesh in the scene
  36208. * @param ray The ray to use to pick meshes
  36209. * @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
  36210. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36211. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36212. * @returns a PickingInfo
  36213. */
  36214. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36215. /**
  36216. * Launch a ray to try to pick a mesh in the scene
  36217. * @param x X position on screen
  36218. * @param y Y position on screen
  36219. * @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
  36220. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36221. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36222. * @returns an array of PickingInfo
  36223. */
  36224. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36225. /**
  36226. * Launch a ray to try to pick a mesh in the scene
  36227. * @param ray Ray to use
  36228. * @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
  36229. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36230. * @returns an array of PickingInfo
  36231. */
  36232. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36233. /**
  36234. * Force the value of meshUnderPointer
  36235. * @param mesh defines the mesh to use
  36236. */
  36237. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36238. /**
  36239. * Gets the mesh under the pointer
  36240. * @returns a Mesh or null if no mesh is under the pointer
  36241. */
  36242. getPointerOverMesh(): Nullable<AbstractMesh>;
  36243. /** @hidden */
  36244. _rebuildGeometries(): void;
  36245. /** @hidden */
  36246. _rebuildTextures(): void;
  36247. private _getByTags;
  36248. /**
  36249. * Get a list of meshes by tags
  36250. * @param tagsQuery defines the tags query to use
  36251. * @param forEach defines a predicate used to filter results
  36252. * @returns an array of Mesh
  36253. */
  36254. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36255. /**
  36256. * Get a list of cameras by tags
  36257. * @param tagsQuery defines the tags query to use
  36258. * @param forEach defines a predicate used to filter results
  36259. * @returns an array of Camera
  36260. */
  36261. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36262. /**
  36263. * Get a list of lights by tags
  36264. * @param tagsQuery defines the tags query to use
  36265. * @param forEach defines a predicate used to filter results
  36266. * @returns an array of Light
  36267. */
  36268. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36269. /**
  36270. * Get a list of materials by tags
  36271. * @param tagsQuery defines the tags query to use
  36272. * @param forEach defines a predicate used to filter results
  36273. * @returns an array of Material
  36274. */
  36275. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36276. /**
  36277. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36278. * This allowed control for front to back rendering or reversly depending of the special needs.
  36279. *
  36280. * @param renderingGroupId The rendering group id corresponding to its index
  36281. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36282. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36283. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36284. */
  36285. 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;
  36286. /**
  36287. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36288. *
  36289. * @param renderingGroupId The rendering group id corresponding to its index
  36290. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36291. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36292. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36293. */
  36294. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36295. /**
  36296. * Gets the current auto clear configuration for one rendering group of the rendering
  36297. * manager.
  36298. * @param index the rendering group index to get the information for
  36299. * @returns The auto clear setup for the requested rendering group
  36300. */
  36301. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36302. private _blockMaterialDirtyMechanism;
  36303. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36304. blockMaterialDirtyMechanism: boolean;
  36305. /**
  36306. * Will flag all materials as dirty to trigger new shader compilation
  36307. * @param flag defines the flag used to specify which material part must be marked as dirty
  36308. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36309. */
  36310. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36311. /** @hidden */
  36312. _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;
  36313. /** @hidden */
  36314. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36315. /** @hidden */
  36316. _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;
  36317. /** @hidden */
  36318. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36319. /** @hidden */
  36320. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36321. /** @hidden */
  36322. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36323. }
  36324. }
  36325. declare module BABYLON {
  36326. /**
  36327. * Set of assets to keep when moving a scene into an asset container.
  36328. */
  36329. export class KeepAssets extends AbstractScene {
  36330. }
  36331. /**
  36332. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36333. */
  36334. export class InstantiatedEntries {
  36335. /**
  36336. * List of new root nodes (eg. nodes with no parent)
  36337. */
  36338. rootNodes: TransformNode[];
  36339. /**
  36340. * List of new skeletons
  36341. */
  36342. skeletons: Skeleton[];
  36343. /**
  36344. * List of new animation groups
  36345. */
  36346. animationGroups: AnimationGroup[];
  36347. }
  36348. /**
  36349. * Container with a set of assets that can be added or removed from a scene.
  36350. */
  36351. export class AssetContainer extends AbstractScene {
  36352. /**
  36353. * The scene the AssetContainer belongs to.
  36354. */
  36355. scene: Scene;
  36356. /**
  36357. * Instantiates an AssetContainer.
  36358. * @param scene The scene the AssetContainer belongs to.
  36359. */
  36360. constructor(scene: Scene);
  36361. /**
  36362. * Instantiate or clone all meshes and add the new ones to the scene.
  36363. * Skeletons and animation groups will all be cloned
  36364. * @param nameFunction defines an optional function used to get new names for clones
  36365. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36366. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36367. */
  36368. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36369. /**
  36370. * Adds all the assets from the container to the scene.
  36371. */
  36372. addAllToScene(): void;
  36373. /**
  36374. * Removes all the assets in the container from the scene
  36375. */
  36376. removeAllFromScene(): void;
  36377. /**
  36378. * Disposes all the assets in the container
  36379. */
  36380. dispose(): void;
  36381. private _moveAssets;
  36382. /**
  36383. * Removes all the assets contained in the scene and adds them to the container.
  36384. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36385. */
  36386. moveAllFromScene(keepAssets?: KeepAssets): void;
  36387. /**
  36388. * 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.
  36389. * @returns the root mesh
  36390. */
  36391. createRootMesh(): Mesh;
  36392. /**
  36393. * Merge animations from this asset container into a scene
  36394. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  36395. * @param animatables set of animatables to retarget to a node from the scene
  36396. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  36397. */
  36398. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  36399. }
  36400. }
  36401. declare module BABYLON {
  36402. /**
  36403. * Defines how the parser contract is defined.
  36404. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36405. */
  36406. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36407. /**
  36408. * Defines how the individual parser contract is defined.
  36409. * These parser can parse an individual asset
  36410. */
  36411. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36412. /**
  36413. * Base class of the scene acting as a container for the different elements composing a scene.
  36414. * This class is dynamically extended by the different components of the scene increasing
  36415. * flexibility and reducing coupling
  36416. */
  36417. export abstract class AbstractScene {
  36418. /**
  36419. * Stores the list of available parsers in the application.
  36420. */
  36421. private static _BabylonFileParsers;
  36422. /**
  36423. * Stores the list of available individual parsers in the application.
  36424. */
  36425. private static _IndividualBabylonFileParsers;
  36426. /**
  36427. * Adds a parser in the list of available ones
  36428. * @param name Defines the name of the parser
  36429. * @param parser Defines the parser to add
  36430. */
  36431. static AddParser(name: string, parser: BabylonFileParser): void;
  36432. /**
  36433. * Gets a general parser from the list of avaialble ones
  36434. * @param name Defines the name of the parser
  36435. * @returns the requested parser or null
  36436. */
  36437. static GetParser(name: string): Nullable<BabylonFileParser>;
  36438. /**
  36439. * Adds n individual parser in the list of available ones
  36440. * @param name Defines the name of the parser
  36441. * @param parser Defines the parser to add
  36442. */
  36443. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36444. /**
  36445. * Gets an individual parser from the list of avaialble ones
  36446. * @param name Defines the name of the parser
  36447. * @returns the requested parser or null
  36448. */
  36449. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36450. /**
  36451. * Parser json data and populate both a scene and its associated container object
  36452. * @param jsonData Defines the data to parse
  36453. * @param scene Defines the scene to parse the data for
  36454. * @param container Defines the container attached to the parsing sequence
  36455. * @param rootUrl Defines the root url of the data
  36456. */
  36457. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36458. /**
  36459. * Gets the list of root nodes (ie. nodes with no parent)
  36460. */
  36461. rootNodes: Node[];
  36462. /** All of the cameras added to this scene
  36463. * @see http://doc.babylonjs.com/babylon101/cameras
  36464. */
  36465. cameras: Camera[];
  36466. /**
  36467. * All of the lights added to this scene
  36468. * @see http://doc.babylonjs.com/babylon101/lights
  36469. */
  36470. lights: Light[];
  36471. /**
  36472. * All of the (abstract) meshes added to this scene
  36473. */
  36474. meshes: AbstractMesh[];
  36475. /**
  36476. * The list of skeletons added to the scene
  36477. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36478. */
  36479. skeletons: Skeleton[];
  36480. /**
  36481. * All of the particle systems added to this scene
  36482. * @see http://doc.babylonjs.com/babylon101/particles
  36483. */
  36484. particleSystems: IParticleSystem[];
  36485. /**
  36486. * Gets a list of Animations associated with the scene
  36487. */
  36488. animations: Animation[];
  36489. /**
  36490. * All of the animation groups added to this scene
  36491. * @see http://doc.babylonjs.com/how_to/group
  36492. */
  36493. animationGroups: AnimationGroup[];
  36494. /**
  36495. * All of the multi-materials added to this scene
  36496. * @see http://doc.babylonjs.com/how_to/multi_materials
  36497. */
  36498. multiMaterials: MultiMaterial[];
  36499. /**
  36500. * All of the materials added to this scene
  36501. * In the context of a Scene, it is not supposed to be modified manually.
  36502. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36503. * Note also that the order of the Material within the array is not significant and might change.
  36504. * @see http://doc.babylonjs.com/babylon101/materials
  36505. */
  36506. materials: Material[];
  36507. /**
  36508. * The list of morph target managers added to the scene
  36509. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36510. */
  36511. morphTargetManagers: MorphTargetManager[];
  36512. /**
  36513. * The list of geometries used in the scene.
  36514. */
  36515. geometries: Geometry[];
  36516. /**
  36517. * All of the tranform nodes added to this scene
  36518. * In the context of a Scene, it is not supposed to be modified manually.
  36519. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36520. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36521. * @see http://doc.babylonjs.com/how_to/transformnode
  36522. */
  36523. transformNodes: TransformNode[];
  36524. /**
  36525. * ActionManagers available on the scene.
  36526. */
  36527. actionManagers: AbstractActionManager[];
  36528. /**
  36529. * Textures to keep.
  36530. */
  36531. textures: BaseTexture[];
  36532. /**
  36533. * Environment texture for the scene
  36534. */
  36535. environmentTexture: Nullable<BaseTexture>;
  36536. /**
  36537. * @returns all meshes, lights, cameras, transformNodes and bones
  36538. */
  36539. getNodes(): Array<Node>;
  36540. }
  36541. }
  36542. declare module BABYLON {
  36543. /**
  36544. * Interface used to define options for Sound class
  36545. */
  36546. export interface ISoundOptions {
  36547. /**
  36548. * Does the sound autoplay once loaded.
  36549. */
  36550. autoplay?: boolean;
  36551. /**
  36552. * Does the sound loop after it finishes playing once.
  36553. */
  36554. loop?: boolean;
  36555. /**
  36556. * Sound's volume
  36557. */
  36558. volume?: number;
  36559. /**
  36560. * Is it a spatial sound?
  36561. */
  36562. spatialSound?: boolean;
  36563. /**
  36564. * Maximum distance to hear that sound
  36565. */
  36566. maxDistance?: number;
  36567. /**
  36568. * Uses user defined attenuation function
  36569. */
  36570. useCustomAttenuation?: boolean;
  36571. /**
  36572. * Define the roll off factor of spatial sounds.
  36573. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36574. */
  36575. rolloffFactor?: number;
  36576. /**
  36577. * Define the reference distance the sound should be heard perfectly.
  36578. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36579. */
  36580. refDistance?: number;
  36581. /**
  36582. * Define the distance attenuation model the sound will follow.
  36583. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36584. */
  36585. distanceModel?: string;
  36586. /**
  36587. * Defines the playback speed (1 by default)
  36588. */
  36589. playbackRate?: number;
  36590. /**
  36591. * Defines if the sound is from a streaming source
  36592. */
  36593. streaming?: boolean;
  36594. /**
  36595. * Defines an optional length (in seconds) inside the sound file
  36596. */
  36597. length?: number;
  36598. /**
  36599. * Defines an optional offset (in seconds) inside the sound file
  36600. */
  36601. offset?: number;
  36602. /**
  36603. * If true, URLs will not be required to state the audio file codec to use.
  36604. */
  36605. skipCodecCheck?: boolean;
  36606. }
  36607. /**
  36608. * Defines a sound that can be played in the application.
  36609. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36610. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36611. */
  36612. export class Sound {
  36613. /**
  36614. * The name of the sound in the scene.
  36615. */
  36616. name: string;
  36617. /**
  36618. * Does the sound autoplay once loaded.
  36619. */
  36620. autoplay: boolean;
  36621. /**
  36622. * Does the sound loop after it finishes playing once.
  36623. */
  36624. loop: boolean;
  36625. /**
  36626. * Does the sound use a custom attenuation curve to simulate the falloff
  36627. * happening when the source gets further away from the camera.
  36628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36629. */
  36630. useCustomAttenuation: boolean;
  36631. /**
  36632. * The sound track id this sound belongs to.
  36633. */
  36634. soundTrackId: number;
  36635. /**
  36636. * Is this sound currently played.
  36637. */
  36638. isPlaying: boolean;
  36639. /**
  36640. * Is this sound currently paused.
  36641. */
  36642. isPaused: boolean;
  36643. /**
  36644. * Does this sound enables spatial sound.
  36645. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36646. */
  36647. spatialSound: boolean;
  36648. /**
  36649. * Define the reference distance the sound should be heard perfectly.
  36650. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36651. */
  36652. refDistance: number;
  36653. /**
  36654. * Define the roll off factor of spatial sounds.
  36655. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36656. */
  36657. rolloffFactor: number;
  36658. /**
  36659. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36660. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36661. */
  36662. maxDistance: number;
  36663. /**
  36664. * Define the distance attenuation model the sound will follow.
  36665. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36666. */
  36667. distanceModel: string;
  36668. /**
  36669. * @hidden
  36670. * Back Compat
  36671. **/
  36672. onended: () => any;
  36673. /**
  36674. * Observable event when the current playing sound finishes.
  36675. */
  36676. onEndedObservable: Observable<Sound>;
  36677. private _panningModel;
  36678. private _playbackRate;
  36679. private _streaming;
  36680. private _startTime;
  36681. private _startOffset;
  36682. private _position;
  36683. /** @hidden */
  36684. _positionInEmitterSpace: boolean;
  36685. private _localDirection;
  36686. private _volume;
  36687. private _isReadyToPlay;
  36688. private _isDirectional;
  36689. private _readyToPlayCallback;
  36690. private _audioBuffer;
  36691. private _soundSource;
  36692. private _streamingSource;
  36693. private _soundPanner;
  36694. private _soundGain;
  36695. private _inputAudioNode;
  36696. private _outputAudioNode;
  36697. private _coneInnerAngle;
  36698. private _coneOuterAngle;
  36699. private _coneOuterGain;
  36700. private _scene;
  36701. private _connectedTransformNode;
  36702. private _customAttenuationFunction;
  36703. private _registerFunc;
  36704. private _isOutputConnected;
  36705. private _htmlAudioElement;
  36706. private _urlType;
  36707. private _length?;
  36708. private _offset?;
  36709. /** @hidden */
  36710. static _SceneComponentInitialization: (scene: Scene) => void;
  36711. /**
  36712. * Create a sound and attach it to a scene
  36713. * @param name Name of your sound
  36714. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36715. * @param scene defines the scene the sound belongs to
  36716. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36717. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36718. */
  36719. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36720. /**
  36721. * Release the sound and its associated resources
  36722. */
  36723. dispose(): void;
  36724. /**
  36725. * Gets if the sounds is ready to be played or not.
  36726. * @returns true if ready, otherwise false
  36727. */
  36728. isReady(): boolean;
  36729. private _soundLoaded;
  36730. /**
  36731. * Sets the data of the sound from an audiobuffer
  36732. * @param audioBuffer The audioBuffer containing the data
  36733. */
  36734. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36735. /**
  36736. * Updates the current sounds options such as maxdistance, loop...
  36737. * @param options A JSON object containing values named as the object properties
  36738. */
  36739. updateOptions(options: ISoundOptions): void;
  36740. private _createSpatialParameters;
  36741. private _updateSpatialParameters;
  36742. /**
  36743. * Switch the panning model to HRTF:
  36744. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36745. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36746. */
  36747. switchPanningModelToHRTF(): void;
  36748. /**
  36749. * Switch the panning model to Equal Power:
  36750. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36751. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36752. */
  36753. switchPanningModelToEqualPower(): void;
  36754. private _switchPanningModel;
  36755. /**
  36756. * Connect this sound to a sound track audio node like gain...
  36757. * @param soundTrackAudioNode the sound track audio node to connect to
  36758. */
  36759. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36760. /**
  36761. * Transform this sound into a directional source
  36762. * @param coneInnerAngle Size of the inner cone in degree
  36763. * @param coneOuterAngle Size of the outer cone in degree
  36764. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36765. */
  36766. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36767. /**
  36768. * Gets or sets the inner angle for the directional cone.
  36769. */
  36770. /**
  36771. * Gets or sets the inner angle for the directional cone.
  36772. */
  36773. directionalConeInnerAngle: number;
  36774. /**
  36775. * Gets or sets the outer angle for the directional cone.
  36776. */
  36777. /**
  36778. * Gets or sets the outer angle for the directional cone.
  36779. */
  36780. directionalConeOuterAngle: number;
  36781. /**
  36782. * Sets the position of the emitter if spatial sound is enabled
  36783. * @param newPosition Defines the new posisiton
  36784. */
  36785. setPosition(newPosition: Vector3): void;
  36786. /**
  36787. * Sets the local direction of the emitter if spatial sound is enabled
  36788. * @param newLocalDirection Defines the new local direction
  36789. */
  36790. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36791. private _updateDirection;
  36792. /** @hidden */
  36793. updateDistanceFromListener(): void;
  36794. /**
  36795. * Sets a new custom attenuation function for the sound.
  36796. * @param callback Defines the function used for the attenuation
  36797. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36798. */
  36799. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36800. /**
  36801. * Play the sound
  36802. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36803. * @param offset (optional) Start the sound at a specific time in seconds
  36804. * @param length (optional) Sound duration (in seconds)
  36805. */
  36806. play(time?: number, offset?: number, length?: number): void;
  36807. private _onended;
  36808. /**
  36809. * Stop the sound
  36810. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36811. */
  36812. stop(time?: number): void;
  36813. /**
  36814. * Put the sound in pause
  36815. */
  36816. pause(): void;
  36817. /**
  36818. * Sets a dedicated volume for this sounds
  36819. * @param newVolume Define the new volume of the sound
  36820. * @param time Define time for gradual change to new volume
  36821. */
  36822. setVolume(newVolume: number, time?: number): void;
  36823. /**
  36824. * Set the sound play back rate
  36825. * @param newPlaybackRate Define the playback rate the sound should be played at
  36826. */
  36827. setPlaybackRate(newPlaybackRate: number): void;
  36828. /**
  36829. * Gets the volume of the sound.
  36830. * @returns the volume of the sound
  36831. */
  36832. getVolume(): number;
  36833. /**
  36834. * Attach the sound to a dedicated mesh
  36835. * @param transformNode The transform node to connect the sound with
  36836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36837. */
  36838. attachToMesh(transformNode: TransformNode): void;
  36839. /**
  36840. * Detach the sound from the previously attached mesh
  36841. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36842. */
  36843. detachFromMesh(): void;
  36844. private _onRegisterAfterWorldMatrixUpdate;
  36845. /**
  36846. * Clone the current sound in the scene.
  36847. * @returns the new sound clone
  36848. */
  36849. clone(): Nullable<Sound>;
  36850. /**
  36851. * Gets the current underlying audio buffer containing the data
  36852. * @returns the audio buffer
  36853. */
  36854. getAudioBuffer(): Nullable<AudioBuffer>;
  36855. /**
  36856. * Serializes the Sound in a JSON representation
  36857. * @returns the JSON representation of the sound
  36858. */
  36859. serialize(): any;
  36860. /**
  36861. * Parse a JSON representation of a sound to innstantiate in a given scene
  36862. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36863. * @param scene Define the scene the new parsed sound should be created in
  36864. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36865. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36866. * @returns the newly parsed sound
  36867. */
  36868. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36869. }
  36870. }
  36871. declare module BABYLON {
  36872. /**
  36873. * This defines an action helpful to play a defined sound on a triggered action.
  36874. */
  36875. export class PlaySoundAction extends Action {
  36876. private _sound;
  36877. /**
  36878. * Instantiate the action
  36879. * @param triggerOptions defines the trigger options
  36880. * @param sound defines the sound to play
  36881. * @param condition defines the trigger related conditions
  36882. */
  36883. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36884. /** @hidden */
  36885. _prepare(): void;
  36886. /**
  36887. * Execute the action and play the sound.
  36888. */
  36889. execute(): void;
  36890. /**
  36891. * Serializes the actions and its related information.
  36892. * @param parent defines the object to serialize in
  36893. * @returns the serialized object
  36894. */
  36895. serialize(parent: any): any;
  36896. }
  36897. /**
  36898. * This defines an action helpful to stop a defined sound on a triggered action.
  36899. */
  36900. export class StopSoundAction extends Action {
  36901. private _sound;
  36902. /**
  36903. * Instantiate the action
  36904. * @param triggerOptions defines the trigger options
  36905. * @param sound defines the sound to stop
  36906. * @param condition defines the trigger related conditions
  36907. */
  36908. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36909. /** @hidden */
  36910. _prepare(): void;
  36911. /**
  36912. * Execute the action and stop the sound.
  36913. */
  36914. execute(): void;
  36915. /**
  36916. * Serializes the actions and its related information.
  36917. * @param parent defines the object to serialize in
  36918. * @returns the serialized object
  36919. */
  36920. serialize(parent: any): any;
  36921. }
  36922. }
  36923. declare module BABYLON {
  36924. /**
  36925. * This defines an action responsible to change the value of a property
  36926. * by interpolating between its current value and the newly set one once triggered.
  36927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36928. */
  36929. export class InterpolateValueAction extends Action {
  36930. /**
  36931. * Defines the path of the property where the value should be interpolated
  36932. */
  36933. propertyPath: string;
  36934. /**
  36935. * Defines the target value at the end of the interpolation.
  36936. */
  36937. value: any;
  36938. /**
  36939. * Defines the time it will take for the property to interpolate to the value.
  36940. */
  36941. duration: number;
  36942. /**
  36943. * Defines if the other scene animations should be stopped when the action has been triggered
  36944. */
  36945. stopOtherAnimations?: boolean;
  36946. /**
  36947. * Defines a callback raised once the interpolation animation has been done.
  36948. */
  36949. onInterpolationDone?: () => void;
  36950. /**
  36951. * Observable triggered once the interpolation animation has been done.
  36952. */
  36953. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36954. private _target;
  36955. private _effectiveTarget;
  36956. private _property;
  36957. /**
  36958. * Instantiate the action
  36959. * @param triggerOptions defines the trigger options
  36960. * @param target defines the object containing the value to interpolate
  36961. * @param propertyPath defines the path to the property in the target object
  36962. * @param value defines the target value at the end of the interpolation
  36963. * @param duration deines the time it will take for the property to interpolate to the value.
  36964. * @param condition defines the trigger related conditions
  36965. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36966. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36967. */
  36968. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36969. /** @hidden */
  36970. _prepare(): void;
  36971. /**
  36972. * Execute the action starts the value interpolation.
  36973. */
  36974. execute(): void;
  36975. /**
  36976. * Serializes the actions and its related information.
  36977. * @param parent defines the object to serialize in
  36978. * @returns the serialized object
  36979. */
  36980. serialize(parent: any): any;
  36981. }
  36982. }
  36983. declare module BABYLON {
  36984. /**
  36985. * Options allowed during the creation of a sound track.
  36986. */
  36987. export interface ISoundTrackOptions {
  36988. /**
  36989. * The volume the sound track should take during creation
  36990. */
  36991. volume?: number;
  36992. /**
  36993. * Define if the sound track is the main sound track of the scene
  36994. */
  36995. mainTrack?: boolean;
  36996. }
  36997. /**
  36998. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36999. * It will be also used in a future release to apply effects on a specific track.
  37000. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37001. */
  37002. export class SoundTrack {
  37003. /**
  37004. * The unique identifier of the sound track in the scene.
  37005. */
  37006. id: number;
  37007. /**
  37008. * The list of sounds included in the sound track.
  37009. */
  37010. soundCollection: Array<Sound>;
  37011. private _outputAudioNode;
  37012. private _scene;
  37013. private _connectedAnalyser;
  37014. private _options;
  37015. private _isInitialized;
  37016. /**
  37017. * Creates a new sound track.
  37018. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37019. * @param scene Define the scene the sound track belongs to
  37020. * @param options
  37021. */
  37022. constructor(scene: Scene, options?: ISoundTrackOptions);
  37023. private _initializeSoundTrackAudioGraph;
  37024. /**
  37025. * Release the sound track and its associated resources
  37026. */
  37027. dispose(): void;
  37028. /**
  37029. * Adds a sound to this sound track
  37030. * @param sound define the cound to add
  37031. * @ignoreNaming
  37032. */
  37033. AddSound(sound: Sound): void;
  37034. /**
  37035. * Removes a sound to this sound track
  37036. * @param sound define the cound to remove
  37037. * @ignoreNaming
  37038. */
  37039. RemoveSound(sound: Sound): void;
  37040. /**
  37041. * Set a global volume for the full sound track.
  37042. * @param newVolume Define the new volume of the sound track
  37043. */
  37044. setVolume(newVolume: number): void;
  37045. /**
  37046. * Switch the panning model to HRTF:
  37047. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37048. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37049. */
  37050. switchPanningModelToHRTF(): void;
  37051. /**
  37052. * Switch the panning model to Equal Power:
  37053. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37054. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37055. */
  37056. switchPanningModelToEqualPower(): void;
  37057. /**
  37058. * Connect the sound track to an audio analyser allowing some amazing
  37059. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37060. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37061. * @param analyser The analyser to connect to the engine
  37062. */
  37063. connectToAnalyser(analyser: Analyser): void;
  37064. }
  37065. }
  37066. declare module BABYLON {
  37067. interface AbstractScene {
  37068. /**
  37069. * The list of sounds used in the scene.
  37070. */
  37071. sounds: Nullable<Array<Sound>>;
  37072. }
  37073. interface Scene {
  37074. /**
  37075. * @hidden
  37076. * Backing field
  37077. */
  37078. _mainSoundTrack: SoundTrack;
  37079. /**
  37080. * The main sound track played by the scene.
  37081. * It cotains your primary collection of sounds.
  37082. */
  37083. mainSoundTrack: SoundTrack;
  37084. /**
  37085. * The list of sound tracks added to the scene
  37086. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37087. */
  37088. soundTracks: Nullable<Array<SoundTrack>>;
  37089. /**
  37090. * Gets a sound using a given name
  37091. * @param name defines the name to search for
  37092. * @return the found sound or null if not found at all.
  37093. */
  37094. getSoundByName(name: string): Nullable<Sound>;
  37095. /**
  37096. * Gets or sets if audio support is enabled
  37097. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37098. */
  37099. audioEnabled: boolean;
  37100. /**
  37101. * Gets or sets if audio will be output to headphones
  37102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37103. */
  37104. headphone: boolean;
  37105. /**
  37106. * Gets or sets custom audio listener position provider
  37107. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37108. */
  37109. audioListenerPositionProvider: Nullable<() => Vector3>;
  37110. /**
  37111. * Gets or sets a refresh rate when using 3D audio positioning
  37112. */
  37113. audioPositioningRefreshRate: number;
  37114. }
  37115. /**
  37116. * Defines the sound scene component responsible to manage any sounds
  37117. * in a given scene.
  37118. */
  37119. export class AudioSceneComponent implements ISceneSerializableComponent {
  37120. /**
  37121. * The component name helpfull to identify the component in the list of scene components.
  37122. */
  37123. readonly name: string;
  37124. /**
  37125. * The scene the component belongs to.
  37126. */
  37127. scene: Scene;
  37128. private _audioEnabled;
  37129. /**
  37130. * Gets whether audio is enabled or not.
  37131. * Please use related enable/disable method to switch state.
  37132. */
  37133. readonly audioEnabled: boolean;
  37134. private _headphone;
  37135. /**
  37136. * Gets whether audio is outputing to headphone or not.
  37137. * Please use the according Switch methods to change output.
  37138. */
  37139. readonly headphone: boolean;
  37140. /**
  37141. * Gets or sets a refresh rate when using 3D audio positioning
  37142. */
  37143. audioPositioningRefreshRate: number;
  37144. private _audioListenerPositionProvider;
  37145. /**
  37146. * Gets the current audio listener position provider
  37147. */
  37148. /**
  37149. * Sets a custom listener position for all sounds in the scene
  37150. * By default, this is the position of the first active camera
  37151. */
  37152. audioListenerPositionProvider: Nullable<() => Vector3>;
  37153. /**
  37154. * Creates a new instance of the component for the given scene
  37155. * @param scene Defines the scene to register the component in
  37156. */
  37157. constructor(scene: Scene);
  37158. /**
  37159. * Registers the component in a given scene
  37160. */
  37161. register(): void;
  37162. /**
  37163. * Rebuilds the elements related to this component in case of
  37164. * context lost for instance.
  37165. */
  37166. rebuild(): void;
  37167. /**
  37168. * Serializes the component data to the specified json object
  37169. * @param serializationObject The object to serialize to
  37170. */
  37171. serialize(serializationObject: any): void;
  37172. /**
  37173. * Adds all the elements from the container to the scene
  37174. * @param container the container holding the elements
  37175. */
  37176. addFromContainer(container: AbstractScene): void;
  37177. /**
  37178. * Removes all the elements in the container from the scene
  37179. * @param container contains the elements to remove
  37180. * @param dispose if the removed element should be disposed (default: false)
  37181. */
  37182. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37183. /**
  37184. * Disposes the component and the associated ressources.
  37185. */
  37186. dispose(): void;
  37187. /**
  37188. * Disables audio in the associated scene.
  37189. */
  37190. disableAudio(): void;
  37191. /**
  37192. * Enables audio in the associated scene.
  37193. */
  37194. enableAudio(): void;
  37195. /**
  37196. * Switch audio to headphone output.
  37197. */
  37198. switchAudioModeForHeadphones(): void;
  37199. /**
  37200. * Switch audio to normal speakers.
  37201. */
  37202. switchAudioModeForNormalSpeakers(): void;
  37203. private _cachedCameraDirection;
  37204. private _cachedCameraPosition;
  37205. private _lastCheck;
  37206. private _afterRender;
  37207. }
  37208. }
  37209. declare module BABYLON {
  37210. /**
  37211. * Wraps one or more Sound objects and selects one with random weight for playback.
  37212. */
  37213. export class WeightedSound {
  37214. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37215. loop: boolean;
  37216. private _coneInnerAngle;
  37217. private _coneOuterAngle;
  37218. private _volume;
  37219. /** A Sound is currently playing. */
  37220. isPlaying: boolean;
  37221. /** A Sound is currently paused. */
  37222. isPaused: boolean;
  37223. private _sounds;
  37224. private _weights;
  37225. private _currentIndex?;
  37226. /**
  37227. * Creates a new WeightedSound from the list of sounds given.
  37228. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37229. * @param sounds Array of Sounds that will be selected from.
  37230. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37231. */
  37232. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37233. /**
  37234. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37235. */
  37236. /**
  37237. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37238. */
  37239. directionalConeInnerAngle: number;
  37240. /**
  37241. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37242. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37243. */
  37244. /**
  37245. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37246. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37247. */
  37248. directionalConeOuterAngle: number;
  37249. /**
  37250. * Playback volume.
  37251. */
  37252. /**
  37253. * Playback volume.
  37254. */
  37255. volume: number;
  37256. private _onended;
  37257. /**
  37258. * Suspend playback
  37259. */
  37260. pause(): void;
  37261. /**
  37262. * Stop playback
  37263. */
  37264. stop(): void;
  37265. /**
  37266. * Start playback.
  37267. * @param startOffset Position the clip head at a specific time in seconds.
  37268. */
  37269. play(startOffset?: number): void;
  37270. }
  37271. }
  37272. declare module BABYLON {
  37273. /**
  37274. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37275. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37276. */
  37277. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37278. /**
  37279. * Gets the name of the behavior.
  37280. */
  37281. readonly name: string;
  37282. /**
  37283. * The easing function used by animations
  37284. */
  37285. static EasingFunction: BackEase;
  37286. /**
  37287. * The easing mode used by animations
  37288. */
  37289. static EasingMode: number;
  37290. /**
  37291. * The duration of the animation, in milliseconds
  37292. */
  37293. transitionDuration: number;
  37294. /**
  37295. * Length of the distance animated by the transition when lower radius is reached
  37296. */
  37297. lowerRadiusTransitionRange: number;
  37298. /**
  37299. * Length of the distance animated by the transition when upper radius is reached
  37300. */
  37301. upperRadiusTransitionRange: number;
  37302. private _autoTransitionRange;
  37303. /**
  37304. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37305. */
  37306. /**
  37307. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37308. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37309. */
  37310. autoTransitionRange: boolean;
  37311. private _attachedCamera;
  37312. private _onAfterCheckInputsObserver;
  37313. private _onMeshTargetChangedObserver;
  37314. /**
  37315. * Initializes the behavior.
  37316. */
  37317. init(): void;
  37318. /**
  37319. * Attaches the behavior to its arc rotate camera.
  37320. * @param camera Defines the camera to attach the behavior to
  37321. */
  37322. attach(camera: ArcRotateCamera): void;
  37323. /**
  37324. * Detaches the behavior from its current arc rotate camera.
  37325. */
  37326. detach(): void;
  37327. private _radiusIsAnimating;
  37328. private _radiusBounceTransition;
  37329. private _animatables;
  37330. private _cachedWheelPrecision;
  37331. /**
  37332. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37333. * @param radiusLimit The limit to check against.
  37334. * @return Bool to indicate if at limit.
  37335. */
  37336. private _isRadiusAtLimit;
  37337. /**
  37338. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37339. * @param radiusDelta The delta by which to animate to. Can be negative.
  37340. */
  37341. private _applyBoundRadiusAnimation;
  37342. /**
  37343. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37344. */
  37345. protected _clearAnimationLocks(): void;
  37346. /**
  37347. * Stops and removes all animations that have been applied to the camera
  37348. */
  37349. stopAllAnimations(): void;
  37350. }
  37351. }
  37352. declare module BABYLON {
  37353. /**
  37354. * 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.
  37355. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37356. */
  37357. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37358. /**
  37359. * Gets the name of the behavior.
  37360. */
  37361. readonly name: string;
  37362. private _mode;
  37363. private _radiusScale;
  37364. private _positionScale;
  37365. private _defaultElevation;
  37366. private _elevationReturnTime;
  37367. private _elevationReturnWaitTime;
  37368. private _zoomStopsAnimation;
  37369. private _framingTime;
  37370. /**
  37371. * The easing function used by animations
  37372. */
  37373. static EasingFunction: ExponentialEase;
  37374. /**
  37375. * The easing mode used by animations
  37376. */
  37377. static EasingMode: number;
  37378. /**
  37379. * Sets the current mode used by the behavior
  37380. */
  37381. /**
  37382. * Gets current mode used by the behavior.
  37383. */
  37384. mode: number;
  37385. /**
  37386. * Sets the scale applied to the radius (1 by default)
  37387. */
  37388. /**
  37389. * Gets the scale applied to the radius
  37390. */
  37391. radiusScale: number;
  37392. /**
  37393. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37394. */
  37395. /**
  37396. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37397. */
  37398. positionScale: number;
  37399. /**
  37400. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37401. * behaviour is triggered, in radians.
  37402. */
  37403. /**
  37404. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37405. * behaviour is triggered, in radians.
  37406. */
  37407. defaultElevation: number;
  37408. /**
  37409. * Sets the time (in milliseconds) taken to return to the default beta position.
  37410. * Negative value indicates camera should not return to default.
  37411. */
  37412. /**
  37413. * Gets the time (in milliseconds) taken to return to the default beta position.
  37414. * Negative value indicates camera should not return to default.
  37415. */
  37416. elevationReturnTime: number;
  37417. /**
  37418. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37419. */
  37420. /**
  37421. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37422. */
  37423. elevationReturnWaitTime: number;
  37424. /**
  37425. * Sets the flag that indicates if user zooming should stop animation.
  37426. */
  37427. /**
  37428. * Gets the flag that indicates if user zooming should stop animation.
  37429. */
  37430. zoomStopsAnimation: boolean;
  37431. /**
  37432. * Sets the transition time when framing the mesh, in milliseconds
  37433. */
  37434. /**
  37435. * Gets the transition time when framing the mesh, in milliseconds
  37436. */
  37437. framingTime: number;
  37438. /**
  37439. * Define if the behavior should automatically change the configured
  37440. * camera limits and sensibilities.
  37441. */
  37442. autoCorrectCameraLimitsAndSensibility: boolean;
  37443. private _onPrePointerObservableObserver;
  37444. private _onAfterCheckInputsObserver;
  37445. private _onMeshTargetChangedObserver;
  37446. private _attachedCamera;
  37447. private _isPointerDown;
  37448. private _lastInteractionTime;
  37449. /**
  37450. * Initializes the behavior.
  37451. */
  37452. init(): void;
  37453. /**
  37454. * Attaches the behavior to its arc rotate camera.
  37455. * @param camera Defines the camera to attach the behavior to
  37456. */
  37457. attach(camera: ArcRotateCamera): void;
  37458. /**
  37459. * Detaches the behavior from its current arc rotate camera.
  37460. */
  37461. detach(): void;
  37462. private _animatables;
  37463. private _betaIsAnimating;
  37464. private _betaTransition;
  37465. private _radiusTransition;
  37466. private _vectorTransition;
  37467. /**
  37468. * Targets the given mesh and updates zoom level accordingly.
  37469. * @param mesh The mesh to target.
  37470. * @param radius Optional. If a cached radius position already exists, overrides default.
  37471. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37472. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37473. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37474. */
  37475. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37476. /**
  37477. * Targets the given mesh with its children and updates zoom level accordingly.
  37478. * @param mesh The mesh to target.
  37479. * @param radius Optional. If a cached radius position already exists, overrides default.
  37480. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37481. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37482. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37483. */
  37484. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37485. /**
  37486. * Targets the given meshes with their children and updates zoom level accordingly.
  37487. * @param meshes The mesh to target.
  37488. * @param radius Optional. If a cached radius position already exists, overrides default.
  37489. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37490. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37491. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37492. */
  37493. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37494. /**
  37495. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37496. * @param minimumWorld Determines the smaller position of the bounding box extend
  37497. * @param maximumWorld Determines the bigger position of the bounding box extend
  37498. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37499. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37500. */
  37501. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37502. /**
  37503. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37504. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37505. * frustum width.
  37506. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37507. * to fully enclose the mesh in the viewing frustum.
  37508. */
  37509. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37510. /**
  37511. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37512. * is automatically returned to its default position (expected to be above ground plane).
  37513. */
  37514. private _maintainCameraAboveGround;
  37515. /**
  37516. * Returns the frustum slope based on the canvas ratio and camera FOV
  37517. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37518. */
  37519. private _getFrustumSlope;
  37520. /**
  37521. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37522. */
  37523. private _clearAnimationLocks;
  37524. /**
  37525. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37526. */
  37527. private _applyUserInteraction;
  37528. /**
  37529. * Stops and removes all animations that have been applied to the camera
  37530. */
  37531. stopAllAnimations(): void;
  37532. /**
  37533. * Gets a value indicating if the user is moving the camera
  37534. */
  37535. readonly isUserIsMoving: boolean;
  37536. /**
  37537. * The camera can move all the way towards the mesh.
  37538. */
  37539. static IgnoreBoundsSizeMode: number;
  37540. /**
  37541. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37542. */
  37543. static FitFrustumSidesMode: number;
  37544. }
  37545. }
  37546. declare module BABYLON {
  37547. /**
  37548. * Base class for Camera Pointer Inputs.
  37549. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37550. * for example usage.
  37551. */
  37552. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37553. /**
  37554. * Defines the camera the input is attached to.
  37555. */
  37556. abstract camera: Camera;
  37557. /**
  37558. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37559. */
  37560. protected _altKey: boolean;
  37561. protected _ctrlKey: boolean;
  37562. protected _metaKey: boolean;
  37563. protected _shiftKey: boolean;
  37564. /**
  37565. * Which mouse buttons were pressed at time of last mouse event.
  37566. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37567. */
  37568. protected _buttonsPressed: number;
  37569. /**
  37570. * Defines the buttons associated with the input to handle camera move.
  37571. */
  37572. buttons: number[];
  37573. /**
  37574. * Attach the input controls to a specific dom element to get the input from.
  37575. * @param element Defines the element the controls should be listened from
  37576. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37577. */
  37578. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37579. /**
  37580. * Detach the current controls from the specified dom element.
  37581. * @param element Defines the element to stop listening the inputs from
  37582. */
  37583. detachControl(element: Nullable<HTMLElement>): void;
  37584. /**
  37585. * Gets the class name of the current input.
  37586. * @returns the class name
  37587. */
  37588. getClassName(): string;
  37589. /**
  37590. * Get the friendly name associated with the input class.
  37591. * @returns the input friendly name
  37592. */
  37593. getSimpleName(): string;
  37594. /**
  37595. * Called on pointer POINTERDOUBLETAP event.
  37596. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37597. */
  37598. protected onDoubleTap(type: string): void;
  37599. /**
  37600. * Called on pointer POINTERMOVE event if only a single touch is active.
  37601. * Override this method to provide functionality.
  37602. */
  37603. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37604. /**
  37605. * Called on pointer POINTERMOVE event if multiple touches are active.
  37606. * Override this method to provide functionality.
  37607. */
  37608. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37609. /**
  37610. * Called on JS contextmenu event.
  37611. * Override this method to provide functionality.
  37612. */
  37613. protected onContextMenu(evt: PointerEvent): void;
  37614. /**
  37615. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37616. * press.
  37617. * Override this method to provide functionality.
  37618. */
  37619. protected onButtonDown(evt: PointerEvent): void;
  37620. /**
  37621. * Called each time a new POINTERUP event occurs. Ie, for each button
  37622. * release.
  37623. * Override this method to provide functionality.
  37624. */
  37625. protected onButtonUp(evt: PointerEvent): void;
  37626. /**
  37627. * Called when window becomes inactive.
  37628. * Override this method to provide functionality.
  37629. */
  37630. protected onLostFocus(): void;
  37631. private _pointerInput;
  37632. private _observer;
  37633. private _onLostFocus;
  37634. private pointA;
  37635. private pointB;
  37636. }
  37637. }
  37638. declare module BABYLON {
  37639. /**
  37640. * Manage the pointers inputs to control an arc rotate camera.
  37641. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37642. */
  37643. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37644. /**
  37645. * Defines the camera the input is attached to.
  37646. */
  37647. camera: ArcRotateCamera;
  37648. /**
  37649. * Gets the class name of the current input.
  37650. * @returns the class name
  37651. */
  37652. getClassName(): string;
  37653. /**
  37654. * Defines the buttons associated with the input to handle camera move.
  37655. */
  37656. buttons: number[];
  37657. /**
  37658. * Defines the pointer angular sensibility along the X axis or how fast is
  37659. * the camera rotating.
  37660. */
  37661. angularSensibilityX: number;
  37662. /**
  37663. * Defines the pointer angular sensibility along the Y axis or how fast is
  37664. * the camera rotating.
  37665. */
  37666. angularSensibilityY: number;
  37667. /**
  37668. * Defines the pointer pinch precision or how fast is the camera zooming.
  37669. */
  37670. pinchPrecision: number;
  37671. /**
  37672. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37673. * from 0.
  37674. * It defines the percentage of current camera.radius to use as delta when
  37675. * pinch zoom is used.
  37676. */
  37677. pinchDeltaPercentage: number;
  37678. /**
  37679. * Defines the pointer panning sensibility or how fast is the camera moving.
  37680. */
  37681. panningSensibility: number;
  37682. /**
  37683. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37684. */
  37685. multiTouchPanning: boolean;
  37686. /**
  37687. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37688. * zoom (pinch) through multitouch.
  37689. */
  37690. multiTouchPanAndZoom: boolean;
  37691. /**
  37692. * Revers pinch action direction.
  37693. */
  37694. pinchInwards: boolean;
  37695. private _isPanClick;
  37696. private _twoFingerActivityCount;
  37697. private _isPinching;
  37698. /**
  37699. * Called on pointer POINTERMOVE event if only a single touch is active.
  37700. */
  37701. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37702. /**
  37703. * Called on pointer POINTERDOUBLETAP event.
  37704. */
  37705. protected onDoubleTap(type: string): void;
  37706. /**
  37707. * Called on pointer POINTERMOVE event if multiple touches are active.
  37708. */
  37709. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37710. /**
  37711. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37712. * press.
  37713. */
  37714. protected onButtonDown(evt: PointerEvent): void;
  37715. /**
  37716. * Called each time a new POINTERUP event occurs. Ie, for each button
  37717. * release.
  37718. */
  37719. protected onButtonUp(evt: PointerEvent): void;
  37720. /**
  37721. * Called when window becomes inactive.
  37722. */
  37723. protected onLostFocus(): void;
  37724. }
  37725. }
  37726. declare module BABYLON {
  37727. /**
  37728. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37729. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37730. */
  37731. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37732. /**
  37733. * Defines the camera the input is attached to.
  37734. */
  37735. camera: ArcRotateCamera;
  37736. /**
  37737. * Defines the list of key codes associated with the up action (increase alpha)
  37738. */
  37739. keysUp: number[];
  37740. /**
  37741. * Defines the list of key codes associated with the down action (decrease alpha)
  37742. */
  37743. keysDown: number[];
  37744. /**
  37745. * Defines the list of key codes associated with the left action (increase beta)
  37746. */
  37747. keysLeft: number[];
  37748. /**
  37749. * Defines the list of key codes associated with the right action (decrease beta)
  37750. */
  37751. keysRight: number[];
  37752. /**
  37753. * Defines the list of key codes associated with the reset action.
  37754. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37755. */
  37756. keysReset: number[];
  37757. /**
  37758. * Defines the panning sensibility of the inputs.
  37759. * (How fast is the camera paning)
  37760. */
  37761. panningSensibility: number;
  37762. /**
  37763. * Defines the zooming sensibility of the inputs.
  37764. * (How fast is the camera zooming)
  37765. */
  37766. zoomingSensibility: number;
  37767. /**
  37768. * Defines wether maintaining the alt key down switch the movement mode from
  37769. * orientation to zoom.
  37770. */
  37771. useAltToZoom: boolean;
  37772. /**
  37773. * Rotation speed of the camera
  37774. */
  37775. angularSpeed: number;
  37776. private _keys;
  37777. private _ctrlPressed;
  37778. private _altPressed;
  37779. private _onCanvasBlurObserver;
  37780. private _onKeyboardObserver;
  37781. private _engine;
  37782. private _scene;
  37783. /**
  37784. * Attach the input controls to a specific dom element to get the input from.
  37785. * @param element Defines the element the controls should be listened from
  37786. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37787. */
  37788. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37789. /**
  37790. * Detach the current controls from the specified dom element.
  37791. * @param element Defines the element to stop listening the inputs from
  37792. */
  37793. detachControl(element: Nullable<HTMLElement>): void;
  37794. /**
  37795. * Update the current camera state depending on the inputs that have been used this frame.
  37796. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37797. */
  37798. checkInputs(): void;
  37799. /**
  37800. * Gets the class name of the current intput.
  37801. * @returns the class name
  37802. */
  37803. getClassName(): string;
  37804. /**
  37805. * Get the friendly name associated with the input class.
  37806. * @returns the input friendly name
  37807. */
  37808. getSimpleName(): string;
  37809. }
  37810. }
  37811. declare module BABYLON {
  37812. /**
  37813. * Manage the mouse wheel inputs to control an arc rotate camera.
  37814. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37815. */
  37816. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37817. /**
  37818. * Defines the camera the input is attached to.
  37819. */
  37820. camera: ArcRotateCamera;
  37821. /**
  37822. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37823. */
  37824. wheelPrecision: number;
  37825. /**
  37826. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37827. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37828. */
  37829. wheelDeltaPercentage: number;
  37830. private _wheel;
  37831. private _observer;
  37832. private computeDeltaFromMouseWheelLegacyEvent;
  37833. /**
  37834. * Attach the input controls to a specific dom element to get the input from.
  37835. * @param element Defines the element the controls should be listened from
  37836. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37837. */
  37838. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37839. /**
  37840. * Detach the current controls from the specified dom element.
  37841. * @param element Defines the element to stop listening the inputs from
  37842. */
  37843. detachControl(element: Nullable<HTMLElement>): void;
  37844. /**
  37845. * Gets the class name of the current intput.
  37846. * @returns the class name
  37847. */
  37848. getClassName(): string;
  37849. /**
  37850. * Get the friendly name associated with the input class.
  37851. * @returns the input friendly name
  37852. */
  37853. getSimpleName(): string;
  37854. }
  37855. }
  37856. declare module BABYLON {
  37857. /**
  37858. * Default Inputs manager for the ArcRotateCamera.
  37859. * It groups all the default supported inputs for ease of use.
  37860. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37861. */
  37862. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37863. /**
  37864. * Instantiates a new ArcRotateCameraInputsManager.
  37865. * @param camera Defines the camera the inputs belong to
  37866. */
  37867. constructor(camera: ArcRotateCamera);
  37868. /**
  37869. * Add mouse wheel input support to the input manager.
  37870. * @returns the current input manager
  37871. */
  37872. addMouseWheel(): ArcRotateCameraInputsManager;
  37873. /**
  37874. * Add pointers input support to the input manager.
  37875. * @returns the current input manager
  37876. */
  37877. addPointers(): ArcRotateCameraInputsManager;
  37878. /**
  37879. * Add keyboard input support to the input manager.
  37880. * @returns the current input manager
  37881. */
  37882. addKeyboard(): ArcRotateCameraInputsManager;
  37883. }
  37884. }
  37885. declare module BABYLON {
  37886. /**
  37887. * This represents an orbital type of camera.
  37888. *
  37889. * 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.
  37890. * 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.
  37891. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37892. */
  37893. export class ArcRotateCamera extends TargetCamera {
  37894. /**
  37895. * Defines the rotation angle of the camera along the longitudinal axis.
  37896. */
  37897. alpha: number;
  37898. /**
  37899. * Defines the rotation angle of the camera along the latitudinal axis.
  37900. */
  37901. beta: number;
  37902. /**
  37903. * Defines the radius of the camera from it s target point.
  37904. */
  37905. radius: number;
  37906. protected _target: Vector3;
  37907. protected _targetHost: Nullable<AbstractMesh>;
  37908. /**
  37909. * Defines the target point of the camera.
  37910. * The camera looks towards it form the radius distance.
  37911. */
  37912. target: Vector3;
  37913. /**
  37914. * Define the current local position of the camera in the scene
  37915. */
  37916. position: Vector3;
  37917. protected _upVector: Vector3;
  37918. protected _upToYMatrix: Matrix;
  37919. protected _YToUpMatrix: Matrix;
  37920. /**
  37921. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37922. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37923. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37924. */
  37925. upVector: Vector3;
  37926. /**
  37927. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37928. */
  37929. setMatUp(): void;
  37930. /**
  37931. * Current inertia value on the longitudinal axis.
  37932. * The bigger this number the longer it will take for the camera to stop.
  37933. */
  37934. inertialAlphaOffset: number;
  37935. /**
  37936. * Current inertia value on the latitudinal axis.
  37937. * The bigger this number the longer it will take for the camera to stop.
  37938. */
  37939. inertialBetaOffset: number;
  37940. /**
  37941. * Current inertia value on the radius axis.
  37942. * The bigger this number the longer it will take for the camera to stop.
  37943. */
  37944. inertialRadiusOffset: number;
  37945. /**
  37946. * Minimum allowed angle on the longitudinal axis.
  37947. * This can help limiting how the Camera is able to move in the scene.
  37948. */
  37949. lowerAlphaLimit: Nullable<number>;
  37950. /**
  37951. * Maximum allowed angle on the longitudinal axis.
  37952. * This can help limiting how the Camera is able to move in the scene.
  37953. */
  37954. upperAlphaLimit: Nullable<number>;
  37955. /**
  37956. * Minimum allowed angle on the latitudinal axis.
  37957. * This can help limiting how the Camera is able to move in the scene.
  37958. */
  37959. lowerBetaLimit: number;
  37960. /**
  37961. * Maximum allowed angle on the latitudinal axis.
  37962. * This can help limiting how the Camera is able to move in the scene.
  37963. */
  37964. upperBetaLimit: number;
  37965. /**
  37966. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37967. * This can help limiting how the Camera is able to move in the scene.
  37968. */
  37969. lowerRadiusLimit: Nullable<number>;
  37970. /**
  37971. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37972. * This can help limiting how the Camera is able to move in the scene.
  37973. */
  37974. upperRadiusLimit: Nullable<number>;
  37975. /**
  37976. * Defines the current inertia value used during panning of the camera along the X axis.
  37977. */
  37978. inertialPanningX: number;
  37979. /**
  37980. * Defines the current inertia value used during panning of the camera along the Y axis.
  37981. */
  37982. inertialPanningY: number;
  37983. /**
  37984. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37985. * Basically if your fingers moves away from more than this distance you will be considered
  37986. * in pinch mode.
  37987. */
  37988. pinchToPanMaxDistance: number;
  37989. /**
  37990. * Defines the maximum distance the camera can pan.
  37991. * This could help keeping the cammera always in your scene.
  37992. */
  37993. panningDistanceLimit: Nullable<number>;
  37994. /**
  37995. * Defines the target of the camera before paning.
  37996. */
  37997. panningOriginTarget: Vector3;
  37998. /**
  37999. * Defines the value of the inertia used during panning.
  38000. * 0 would mean stop inertia and one would mean no decelleration at all.
  38001. */
  38002. panningInertia: number;
  38003. /**
  38004. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38005. */
  38006. angularSensibilityX: number;
  38007. /**
  38008. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38009. */
  38010. angularSensibilityY: number;
  38011. /**
  38012. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38013. */
  38014. pinchPrecision: number;
  38015. /**
  38016. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38017. * It will be used instead of pinchDeltaPrecision if different from 0.
  38018. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38019. */
  38020. pinchDeltaPercentage: number;
  38021. /**
  38022. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38023. */
  38024. panningSensibility: number;
  38025. /**
  38026. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38027. */
  38028. keysUp: number[];
  38029. /**
  38030. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38031. */
  38032. keysDown: number[];
  38033. /**
  38034. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38035. */
  38036. keysLeft: number[];
  38037. /**
  38038. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38039. */
  38040. keysRight: number[];
  38041. /**
  38042. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38043. */
  38044. wheelPrecision: number;
  38045. /**
  38046. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38047. * It will be used instead of pinchDeltaPrecision if different from 0.
  38048. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38049. */
  38050. wheelDeltaPercentage: number;
  38051. /**
  38052. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38053. */
  38054. zoomOnFactor: number;
  38055. /**
  38056. * Defines a screen offset for the camera position.
  38057. */
  38058. targetScreenOffset: Vector2;
  38059. /**
  38060. * Allows the camera to be completely reversed.
  38061. * If false the camera can not arrive upside down.
  38062. */
  38063. allowUpsideDown: boolean;
  38064. /**
  38065. * Define if double tap/click is used to restore the previously saved state of the camera.
  38066. */
  38067. useInputToRestoreState: boolean;
  38068. /** @hidden */
  38069. _viewMatrix: Matrix;
  38070. /** @hidden */
  38071. _useCtrlForPanning: boolean;
  38072. /** @hidden */
  38073. _panningMouseButton: number;
  38074. /**
  38075. * Defines the input associated to the camera.
  38076. */
  38077. inputs: ArcRotateCameraInputsManager;
  38078. /** @hidden */
  38079. _reset: () => void;
  38080. /**
  38081. * Defines the allowed panning axis.
  38082. */
  38083. panningAxis: Vector3;
  38084. protected _localDirection: Vector3;
  38085. protected _transformedDirection: Vector3;
  38086. private _bouncingBehavior;
  38087. /**
  38088. * Gets the bouncing behavior of the camera if it has been enabled.
  38089. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38090. */
  38091. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  38092. /**
  38093. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38094. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38095. */
  38096. useBouncingBehavior: boolean;
  38097. private _framingBehavior;
  38098. /**
  38099. * Gets the framing behavior of the camera if it has been enabled.
  38100. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38101. */
  38102. readonly framingBehavior: Nullable<FramingBehavior>;
  38103. /**
  38104. * Defines if the framing behavior of the camera is enabled on the camera.
  38105. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38106. */
  38107. useFramingBehavior: boolean;
  38108. private _autoRotationBehavior;
  38109. /**
  38110. * Gets the auto rotation behavior of the camera if it has been enabled.
  38111. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38112. */
  38113. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  38114. /**
  38115. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38116. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38117. */
  38118. useAutoRotationBehavior: boolean;
  38119. /**
  38120. * Observable triggered when the mesh target has been changed on the camera.
  38121. */
  38122. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38123. /**
  38124. * Event raised when the camera is colliding with a mesh.
  38125. */
  38126. onCollide: (collidedMesh: AbstractMesh) => void;
  38127. /**
  38128. * Defines whether the camera should check collision with the objects oh the scene.
  38129. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38130. */
  38131. checkCollisions: boolean;
  38132. /**
  38133. * Defines the collision radius of the camera.
  38134. * This simulates a sphere around the camera.
  38135. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38136. */
  38137. collisionRadius: Vector3;
  38138. protected _collider: Collider;
  38139. protected _previousPosition: Vector3;
  38140. protected _collisionVelocity: Vector3;
  38141. protected _newPosition: Vector3;
  38142. protected _previousAlpha: number;
  38143. protected _previousBeta: number;
  38144. protected _previousRadius: number;
  38145. protected _collisionTriggered: boolean;
  38146. protected _targetBoundingCenter: Nullable<Vector3>;
  38147. private _computationVector;
  38148. /**
  38149. * Instantiates a new ArcRotateCamera in a given scene
  38150. * @param name Defines the name of the camera
  38151. * @param alpha Defines the camera rotation along the logitudinal axis
  38152. * @param beta Defines the camera rotation along the latitudinal axis
  38153. * @param radius Defines the camera distance from its target
  38154. * @param target Defines the camera target
  38155. * @param scene Defines the scene the camera belongs to
  38156. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38157. */
  38158. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38159. /** @hidden */
  38160. _initCache(): void;
  38161. /** @hidden */
  38162. _updateCache(ignoreParentClass?: boolean): void;
  38163. protected _getTargetPosition(): Vector3;
  38164. private _storedAlpha;
  38165. private _storedBeta;
  38166. private _storedRadius;
  38167. private _storedTarget;
  38168. private _storedTargetScreenOffset;
  38169. /**
  38170. * Stores the current state of the camera (alpha, beta, radius and target)
  38171. * @returns the camera itself
  38172. */
  38173. storeState(): Camera;
  38174. /**
  38175. * @hidden
  38176. * Restored camera state. You must call storeState() first
  38177. */
  38178. _restoreStateValues(): boolean;
  38179. /** @hidden */
  38180. _isSynchronizedViewMatrix(): boolean;
  38181. /**
  38182. * Attached controls to the current camera.
  38183. * @param element Defines the element the controls should be listened from
  38184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38185. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38186. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38187. */
  38188. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38189. /**
  38190. * Detach the current controls from the camera.
  38191. * The camera will stop reacting to inputs.
  38192. * @param element Defines the element to stop listening the inputs from
  38193. */
  38194. detachControl(element: HTMLElement): void;
  38195. /** @hidden */
  38196. _checkInputs(): void;
  38197. protected _checkLimits(): void;
  38198. /**
  38199. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38200. */
  38201. rebuildAnglesAndRadius(): void;
  38202. /**
  38203. * Use a position to define the current camera related information like alpha, beta and radius
  38204. * @param position Defines the position to set the camera at
  38205. */
  38206. setPosition(position: Vector3): void;
  38207. /**
  38208. * Defines the target the camera should look at.
  38209. * This will automatically adapt alpha beta and radius to fit within the new target.
  38210. * @param target Defines the new target as a Vector or a mesh
  38211. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38212. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38213. */
  38214. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38215. /** @hidden */
  38216. _getViewMatrix(): Matrix;
  38217. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38218. /**
  38219. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38220. * @param meshes Defines the mesh to zoom on
  38221. * @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)
  38222. */
  38223. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38224. /**
  38225. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38226. * The target will be changed but the radius
  38227. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38228. * @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)
  38229. */
  38230. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38231. min: Vector3;
  38232. max: Vector3;
  38233. distance: number;
  38234. }, doNotUpdateMaxZ?: boolean): void;
  38235. /**
  38236. * @override
  38237. * Override Camera.createRigCamera
  38238. */
  38239. createRigCamera(name: string, cameraIndex: number): Camera;
  38240. /**
  38241. * @hidden
  38242. * @override
  38243. * Override Camera._updateRigCameras
  38244. */
  38245. _updateRigCameras(): void;
  38246. /**
  38247. * Destroy the camera and release the current resources hold by it.
  38248. */
  38249. dispose(): void;
  38250. /**
  38251. * Gets the current object class name.
  38252. * @return the class name
  38253. */
  38254. getClassName(): string;
  38255. }
  38256. }
  38257. declare module BABYLON {
  38258. /**
  38259. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38260. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38261. */
  38262. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38263. /**
  38264. * Gets the name of the behavior.
  38265. */
  38266. readonly name: string;
  38267. private _zoomStopsAnimation;
  38268. private _idleRotationSpeed;
  38269. private _idleRotationWaitTime;
  38270. private _idleRotationSpinupTime;
  38271. /**
  38272. * Sets the flag that indicates if user zooming should stop animation.
  38273. */
  38274. /**
  38275. * Gets the flag that indicates if user zooming should stop animation.
  38276. */
  38277. zoomStopsAnimation: boolean;
  38278. /**
  38279. * Sets the default speed at which the camera rotates around the model.
  38280. */
  38281. /**
  38282. * Gets the default speed at which the camera rotates around the model.
  38283. */
  38284. idleRotationSpeed: number;
  38285. /**
  38286. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38287. */
  38288. /**
  38289. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38290. */
  38291. idleRotationWaitTime: number;
  38292. /**
  38293. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38294. */
  38295. /**
  38296. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38297. */
  38298. idleRotationSpinupTime: number;
  38299. /**
  38300. * Gets a value indicating if the camera is currently rotating because of this behavior
  38301. */
  38302. readonly rotationInProgress: boolean;
  38303. private _onPrePointerObservableObserver;
  38304. private _onAfterCheckInputsObserver;
  38305. private _attachedCamera;
  38306. private _isPointerDown;
  38307. private _lastFrameTime;
  38308. private _lastInteractionTime;
  38309. private _cameraRotationSpeed;
  38310. /**
  38311. * Initializes the behavior.
  38312. */
  38313. init(): void;
  38314. /**
  38315. * Attaches the behavior to its arc rotate camera.
  38316. * @param camera Defines the camera to attach the behavior to
  38317. */
  38318. attach(camera: ArcRotateCamera): void;
  38319. /**
  38320. * Detaches the behavior from its current arc rotate camera.
  38321. */
  38322. detach(): void;
  38323. /**
  38324. * Returns true if user is scrolling.
  38325. * @return true if user is scrolling.
  38326. */
  38327. private _userIsZooming;
  38328. private _lastFrameRadius;
  38329. private _shouldAnimationStopForInteraction;
  38330. /**
  38331. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38332. */
  38333. private _applyUserInteraction;
  38334. private _userIsMoving;
  38335. }
  38336. }
  38337. declare module BABYLON {
  38338. /**
  38339. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38340. */
  38341. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38342. private ui;
  38343. /**
  38344. * The name of the behavior
  38345. */
  38346. name: string;
  38347. /**
  38348. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38349. */
  38350. distanceAwayFromFace: number;
  38351. /**
  38352. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38353. */
  38354. distanceAwayFromBottomOfFace: number;
  38355. private _faceVectors;
  38356. private _target;
  38357. private _scene;
  38358. private _onRenderObserver;
  38359. private _tmpMatrix;
  38360. private _tmpVector;
  38361. /**
  38362. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38363. * @param ui The transform node that should be attched to the mesh
  38364. */
  38365. constructor(ui: TransformNode);
  38366. /**
  38367. * Initializes the behavior
  38368. */
  38369. init(): void;
  38370. private _closestFace;
  38371. private _zeroVector;
  38372. private _lookAtTmpMatrix;
  38373. private _lookAtToRef;
  38374. /**
  38375. * Attaches the AttachToBoxBehavior to the passed in mesh
  38376. * @param target The mesh that the specified node will be attached to
  38377. */
  38378. attach(target: Mesh): void;
  38379. /**
  38380. * Detaches the behavior from the mesh
  38381. */
  38382. detach(): void;
  38383. }
  38384. }
  38385. declare module BABYLON {
  38386. /**
  38387. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38388. */
  38389. export class FadeInOutBehavior implements Behavior<Mesh> {
  38390. /**
  38391. * Time in milliseconds to delay before fading in (Default: 0)
  38392. */
  38393. delay: number;
  38394. /**
  38395. * Time in milliseconds for the mesh to fade in (Default: 300)
  38396. */
  38397. fadeInTime: number;
  38398. private _millisecondsPerFrame;
  38399. private _hovered;
  38400. private _hoverValue;
  38401. private _ownerNode;
  38402. /**
  38403. * Instatiates the FadeInOutBehavior
  38404. */
  38405. constructor();
  38406. /**
  38407. * The name of the behavior
  38408. */
  38409. readonly name: string;
  38410. /**
  38411. * Initializes the behavior
  38412. */
  38413. init(): void;
  38414. /**
  38415. * Attaches the fade behavior on the passed in mesh
  38416. * @param ownerNode The mesh that will be faded in/out once attached
  38417. */
  38418. attach(ownerNode: Mesh): void;
  38419. /**
  38420. * Detaches the behavior from the mesh
  38421. */
  38422. detach(): void;
  38423. /**
  38424. * Triggers the mesh to begin fading in or out
  38425. * @param value if the object should fade in or out (true to fade in)
  38426. */
  38427. fadeIn(value: boolean): void;
  38428. private _update;
  38429. private _setAllVisibility;
  38430. }
  38431. }
  38432. declare module BABYLON {
  38433. /**
  38434. * Class containing a set of static utilities functions for managing Pivots
  38435. * @hidden
  38436. */
  38437. export class PivotTools {
  38438. private static _PivotCached;
  38439. private static _OldPivotPoint;
  38440. private static _PivotTranslation;
  38441. private static _PivotTmpVector;
  38442. /** @hidden */
  38443. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38444. /** @hidden */
  38445. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38446. }
  38447. }
  38448. declare module BABYLON {
  38449. /**
  38450. * Class containing static functions to help procedurally build meshes
  38451. */
  38452. export class PlaneBuilder {
  38453. /**
  38454. * Creates a plane mesh
  38455. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38456. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38457. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38459. * * 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
  38460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38461. * @param name defines the name of the mesh
  38462. * @param options defines the options used to create the mesh
  38463. * @param scene defines the hosting scene
  38464. * @returns the plane mesh
  38465. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38466. */
  38467. static CreatePlane(name: string, options: {
  38468. size?: number;
  38469. width?: number;
  38470. height?: number;
  38471. sideOrientation?: number;
  38472. frontUVs?: Vector4;
  38473. backUVs?: Vector4;
  38474. updatable?: boolean;
  38475. sourcePlane?: Plane;
  38476. }, scene?: Nullable<Scene>): Mesh;
  38477. }
  38478. }
  38479. declare module BABYLON {
  38480. /**
  38481. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38482. */
  38483. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38484. private static _AnyMouseID;
  38485. /**
  38486. * Abstract mesh the behavior is set on
  38487. */
  38488. attachedNode: AbstractMesh;
  38489. private _dragPlane;
  38490. private _scene;
  38491. private _pointerObserver;
  38492. private _beforeRenderObserver;
  38493. private static _planeScene;
  38494. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38495. /**
  38496. * 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)
  38497. */
  38498. maxDragAngle: number;
  38499. /**
  38500. * @hidden
  38501. */
  38502. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38503. /**
  38504. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38505. */
  38506. currentDraggingPointerID: number;
  38507. /**
  38508. * The last position where the pointer hit the drag plane in world space
  38509. */
  38510. lastDragPosition: Vector3;
  38511. /**
  38512. * If the behavior is currently in a dragging state
  38513. */
  38514. dragging: boolean;
  38515. /**
  38516. * 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)
  38517. */
  38518. dragDeltaRatio: number;
  38519. /**
  38520. * If the drag plane orientation should be updated during the dragging (Default: true)
  38521. */
  38522. updateDragPlane: boolean;
  38523. private _debugMode;
  38524. private _moving;
  38525. /**
  38526. * Fires each time the attached mesh is dragged with the pointer
  38527. * * delta between last drag position and current drag position in world space
  38528. * * dragDistance along the drag axis
  38529. * * dragPlaneNormal normal of the current drag plane used during the drag
  38530. * * dragPlanePoint in world space where the drag intersects the drag plane
  38531. */
  38532. onDragObservable: Observable<{
  38533. delta: Vector3;
  38534. dragPlanePoint: Vector3;
  38535. dragPlaneNormal: Vector3;
  38536. dragDistance: number;
  38537. pointerId: number;
  38538. }>;
  38539. /**
  38540. * Fires each time a drag begins (eg. mouse down on mesh)
  38541. */
  38542. onDragStartObservable: Observable<{
  38543. dragPlanePoint: Vector3;
  38544. pointerId: number;
  38545. }>;
  38546. /**
  38547. * Fires each time a drag ends (eg. mouse release after drag)
  38548. */
  38549. onDragEndObservable: Observable<{
  38550. dragPlanePoint: Vector3;
  38551. pointerId: number;
  38552. }>;
  38553. /**
  38554. * If the attached mesh should be moved when dragged
  38555. */
  38556. moveAttached: boolean;
  38557. /**
  38558. * If the drag behavior will react to drag events (Default: true)
  38559. */
  38560. enabled: boolean;
  38561. /**
  38562. * If pointer events should start and release the drag (Default: true)
  38563. */
  38564. startAndReleaseDragOnPointerEvents: boolean;
  38565. /**
  38566. * If camera controls should be detached during the drag
  38567. */
  38568. detachCameraControls: boolean;
  38569. /**
  38570. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38571. */
  38572. useObjectOrienationForDragging: boolean;
  38573. private _options;
  38574. /**
  38575. * Gets the options used by the behavior
  38576. */
  38577. /**
  38578. * Sets the options used by the behavior
  38579. */
  38580. options: {
  38581. dragAxis?: Vector3;
  38582. dragPlaneNormal?: Vector3;
  38583. };
  38584. /**
  38585. * Creates a pointer drag behavior that can be attached to a mesh
  38586. * @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)
  38587. */
  38588. constructor(options?: {
  38589. dragAxis?: Vector3;
  38590. dragPlaneNormal?: Vector3;
  38591. });
  38592. /**
  38593. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38594. */
  38595. validateDrag: (targetPosition: Vector3) => boolean;
  38596. /**
  38597. * The name of the behavior
  38598. */
  38599. readonly name: string;
  38600. /**
  38601. * Initializes the behavior
  38602. */
  38603. init(): void;
  38604. private _tmpVector;
  38605. private _alternatePickedPoint;
  38606. private _worldDragAxis;
  38607. private _targetPosition;
  38608. private _attachedElement;
  38609. /**
  38610. * Attaches the drag behavior the passed in mesh
  38611. * @param ownerNode The mesh that will be dragged around once attached
  38612. * @param predicate Predicate to use for pick filtering
  38613. */
  38614. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38615. /**
  38616. * Force relase the drag action by code.
  38617. */
  38618. releaseDrag(): void;
  38619. private _startDragRay;
  38620. private _lastPointerRay;
  38621. /**
  38622. * Simulates the start of a pointer drag event on the behavior
  38623. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38624. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38625. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38626. */
  38627. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38628. private _startDrag;
  38629. private _dragDelta;
  38630. private _moveDrag;
  38631. private _pickWithRayOnDragPlane;
  38632. private _pointA;
  38633. private _pointB;
  38634. private _pointC;
  38635. private _lineA;
  38636. private _lineB;
  38637. private _localAxis;
  38638. private _lookAt;
  38639. private _updateDragPlanePosition;
  38640. /**
  38641. * Detaches the behavior from the mesh
  38642. */
  38643. detach(): void;
  38644. }
  38645. }
  38646. declare module BABYLON {
  38647. /**
  38648. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38649. */
  38650. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38651. private _dragBehaviorA;
  38652. private _dragBehaviorB;
  38653. private _startDistance;
  38654. private _initialScale;
  38655. private _targetScale;
  38656. private _ownerNode;
  38657. private _sceneRenderObserver;
  38658. /**
  38659. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38660. */
  38661. constructor();
  38662. /**
  38663. * The name of the behavior
  38664. */
  38665. readonly name: string;
  38666. /**
  38667. * Initializes the behavior
  38668. */
  38669. init(): void;
  38670. private _getCurrentDistance;
  38671. /**
  38672. * Attaches the scale behavior the passed in mesh
  38673. * @param ownerNode The mesh that will be scaled around once attached
  38674. */
  38675. attach(ownerNode: Mesh): void;
  38676. /**
  38677. * Detaches the behavior from the mesh
  38678. */
  38679. detach(): void;
  38680. }
  38681. }
  38682. declare module BABYLON {
  38683. /**
  38684. * 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
  38685. */
  38686. export class SixDofDragBehavior implements Behavior<Mesh> {
  38687. private static _virtualScene;
  38688. private _ownerNode;
  38689. private _sceneRenderObserver;
  38690. private _scene;
  38691. private _targetPosition;
  38692. private _virtualOriginMesh;
  38693. private _virtualDragMesh;
  38694. private _pointerObserver;
  38695. private _moving;
  38696. private _startingOrientation;
  38697. /**
  38698. * 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)
  38699. */
  38700. private zDragFactor;
  38701. /**
  38702. * If the object should rotate to face the drag origin
  38703. */
  38704. rotateDraggedObject: boolean;
  38705. /**
  38706. * If the behavior is currently in a dragging state
  38707. */
  38708. dragging: boolean;
  38709. /**
  38710. * 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)
  38711. */
  38712. dragDeltaRatio: number;
  38713. /**
  38714. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38715. */
  38716. currentDraggingPointerID: number;
  38717. /**
  38718. * If camera controls should be detached during the drag
  38719. */
  38720. detachCameraControls: boolean;
  38721. /**
  38722. * Fires each time a drag starts
  38723. */
  38724. onDragStartObservable: Observable<{}>;
  38725. /**
  38726. * Fires each time a drag ends (eg. mouse release after drag)
  38727. */
  38728. onDragEndObservable: Observable<{}>;
  38729. /**
  38730. * 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
  38731. */
  38732. constructor();
  38733. /**
  38734. * The name of the behavior
  38735. */
  38736. readonly name: string;
  38737. /**
  38738. * Initializes the behavior
  38739. */
  38740. init(): void;
  38741. /**
  38742. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38743. */
  38744. private readonly _pointerCamera;
  38745. /**
  38746. * Attaches the scale behavior the passed in mesh
  38747. * @param ownerNode The mesh that will be scaled around once attached
  38748. */
  38749. attach(ownerNode: Mesh): void;
  38750. /**
  38751. * Detaches the behavior from the mesh
  38752. */
  38753. detach(): void;
  38754. }
  38755. }
  38756. declare module BABYLON {
  38757. /**
  38758. * Class used to apply inverse kinematics to bones
  38759. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38760. */
  38761. export class BoneIKController {
  38762. private static _tmpVecs;
  38763. private static _tmpQuat;
  38764. private static _tmpMats;
  38765. /**
  38766. * Gets or sets the target mesh
  38767. */
  38768. targetMesh: AbstractMesh;
  38769. /** Gets or sets the mesh used as pole */
  38770. poleTargetMesh: AbstractMesh;
  38771. /**
  38772. * Gets or sets the bone used as pole
  38773. */
  38774. poleTargetBone: Nullable<Bone>;
  38775. /**
  38776. * Gets or sets the target position
  38777. */
  38778. targetPosition: Vector3;
  38779. /**
  38780. * Gets or sets the pole target position
  38781. */
  38782. poleTargetPosition: Vector3;
  38783. /**
  38784. * Gets or sets the pole target local offset
  38785. */
  38786. poleTargetLocalOffset: Vector3;
  38787. /**
  38788. * Gets or sets the pole angle
  38789. */
  38790. poleAngle: number;
  38791. /**
  38792. * Gets or sets the mesh associated with the controller
  38793. */
  38794. mesh: AbstractMesh;
  38795. /**
  38796. * 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)
  38797. */
  38798. slerpAmount: number;
  38799. private _bone1Quat;
  38800. private _bone1Mat;
  38801. private _bone2Ang;
  38802. private _bone1;
  38803. private _bone2;
  38804. private _bone1Length;
  38805. private _bone2Length;
  38806. private _maxAngle;
  38807. private _maxReach;
  38808. private _rightHandedSystem;
  38809. private _bendAxis;
  38810. private _slerping;
  38811. private _adjustRoll;
  38812. /**
  38813. * Gets or sets maximum allowed angle
  38814. */
  38815. maxAngle: number;
  38816. /**
  38817. * Creates a new BoneIKController
  38818. * @param mesh defines the mesh to control
  38819. * @param bone defines the bone to control
  38820. * @param options defines options to set up the controller
  38821. */
  38822. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38823. targetMesh?: AbstractMesh;
  38824. poleTargetMesh?: AbstractMesh;
  38825. poleTargetBone?: Bone;
  38826. poleTargetLocalOffset?: Vector3;
  38827. poleAngle?: number;
  38828. bendAxis?: Vector3;
  38829. maxAngle?: number;
  38830. slerpAmount?: number;
  38831. });
  38832. private _setMaxAngle;
  38833. /**
  38834. * Force the controller to update the bones
  38835. */
  38836. update(): void;
  38837. }
  38838. }
  38839. declare module BABYLON {
  38840. /**
  38841. * Class used to make a bone look toward a point in space
  38842. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38843. */
  38844. export class BoneLookController {
  38845. private static _tmpVecs;
  38846. private static _tmpQuat;
  38847. private static _tmpMats;
  38848. /**
  38849. * The target Vector3 that the bone will look at
  38850. */
  38851. target: Vector3;
  38852. /**
  38853. * The mesh that the bone is attached to
  38854. */
  38855. mesh: AbstractMesh;
  38856. /**
  38857. * The bone that will be looking to the target
  38858. */
  38859. bone: Bone;
  38860. /**
  38861. * The up axis of the coordinate system that is used when the bone is rotated
  38862. */
  38863. upAxis: Vector3;
  38864. /**
  38865. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38866. */
  38867. upAxisSpace: Space;
  38868. /**
  38869. * Used to make an adjustment to the yaw of the bone
  38870. */
  38871. adjustYaw: number;
  38872. /**
  38873. * Used to make an adjustment to the pitch of the bone
  38874. */
  38875. adjustPitch: number;
  38876. /**
  38877. * Used to make an adjustment to the roll of the bone
  38878. */
  38879. adjustRoll: number;
  38880. /**
  38881. * 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)
  38882. */
  38883. slerpAmount: number;
  38884. private _minYaw;
  38885. private _maxYaw;
  38886. private _minPitch;
  38887. private _maxPitch;
  38888. private _minYawSin;
  38889. private _minYawCos;
  38890. private _maxYawSin;
  38891. private _maxYawCos;
  38892. private _midYawConstraint;
  38893. private _minPitchTan;
  38894. private _maxPitchTan;
  38895. private _boneQuat;
  38896. private _slerping;
  38897. private _transformYawPitch;
  38898. private _transformYawPitchInv;
  38899. private _firstFrameSkipped;
  38900. private _yawRange;
  38901. private _fowardAxis;
  38902. /**
  38903. * Gets or sets the minimum yaw angle that the bone can look to
  38904. */
  38905. minYaw: number;
  38906. /**
  38907. * Gets or sets the maximum yaw angle that the bone can look to
  38908. */
  38909. maxYaw: number;
  38910. /**
  38911. * Gets or sets the minimum pitch angle that the bone can look to
  38912. */
  38913. minPitch: number;
  38914. /**
  38915. * Gets or sets the maximum pitch angle that the bone can look to
  38916. */
  38917. maxPitch: number;
  38918. /**
  38919. * Create a BoneLookController
  38920. * @param mesh the mesh that the bone belongs to
  38921. * @param bone the bone that will be looking to the target
  38922. * @param target the target Vector3 to look at
  38923. * @param options optional settings:
  38924. * * maxYaw: the maximum angle the bone will yaw to
  38925. * * minYaw: the minimum angle the bone will yaw to
  38926. * * maxPitch: the maximum angle the bone will pitch to
  38927. * * minPitch: the minimum angle the bone will yaw to
  38928. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38929. * * upAxis: the up axis of the coordinate system
  38930. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38931. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38932. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38933. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38934. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38935. * * adjustRoll: used to make an adjustment to the roll of the bone
  38936. **/
  38937. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38938. maxYaw?: number;
  38939. minYaw?: number;
  38940. maxPitch?: number;
  38941. minPitch?: number;
  38942. slerpAmount?: number;
  38943. upAxis?: Vector3;
  38944. upAxisSpace?: Space;
  38945. yawAxis?: Vector3;
  38946. pitchAxis?: Vector3;
  38947. adjustYaw?: number;
  38948. adjustPitch?: number;
  38949. adjustRoll?: number;
  38950. });
  38951. /**
  38952. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38953. */
  38954. update(): void;
  38955. private _getAngleDiff;
  38956. private _getAngleBetween;
  38957. private _isAngleBetween;
  38958. }
  38959. }
  38960. declare module BABYLON {
  38961. /**
  38962. * Manage the gamepad inputs to control an arc rotate camera.
  38963. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38964. */
  38965. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38966. /**
  38967. * Defines the camera the input is attached to.
  38968. */
  38969. camera: ArcRotateCamera;
  38970. /**
  38971. * Defines the gamepad the input is gathering event from.
  38972. */
  38973. gamepad: Nullable<Gamepad>;
  38974. /**
  38975. * Defines the gamepad rotation sensiblity.
  38976. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38977. */
  38978. gamepadRotationSensibility: number;
  38979. /**
  38980. * Defines the gamepad move sensiblity.
  38981. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38982. */
  38983. gamepadMoveSensibility: number;
  38984. private _yAxisScale;
  38985. /**
  38986. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38987. */
  38988. invertYAxis: boolean;
  38989. private _onGamepadConnectedObserver;
  38990. private _onGamepadDisconnectedObserver;
  38991. /**
  38992. * Attach the input controls to a specific dom element to get the input from.
  38993. * @param element Defines the element the controls should be listened from
  38994. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38995. */
  38996. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38997. /**
  38998. * Detach the current controls from the specified dom element.
  38999. * @param element Defines the element to stop listening the inputs from
  39000. */
  39001. detachControl(element: Nullable<HTMLElement>): void;
  39002. /**
  39003. * Update the current camera state depending on the inputs that have been used this frame.
  39004. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39005. */
  39006. checkInputs(): void;
  39007. /**
  39008. * Gets the class name of the current intput.
  39009. * @returns the class name
  39010. */
  39011. getClassName(): string;
  39012. /**
  39013. * Get the friendly name associated with the input class.
  39014. * @returns the input friendly name
  39015. */
  39016. getSimpleName(): string;
  39017. }
  39018. }
  39019. declare module BABYLON {
  39020. interface ArcRotateCameraInputsManager {
  39021. /**
  39022. * Add orientation input support to the input manager.
  39023. * @returns the current input manager
  39024. */
  39025. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39026. }
  39027. /**
  39028. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39029. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39030. */
  39031. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39032. /**
  39033. * Defines the camera the input is attached to.
  39034. */
  39035. camera: ArcRotateCamera;
  39036. /**
  39037. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39038. */
  39039. alphaCorrection: number;
  39040. /**
  39041. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39042. */
  39043. gammaCorrection: number;
  39044. private _alpha;
  39045. private _gamma;
  39046. private _dirty;
  39047. private _deviceOrientationHandler;
  39048. /**
  39049. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39050. */
  39051. constructor();
  39052. /**
  39053. * Attach the input controls to a specific dom element to get the input from.
  39054. * @param element Defines the element the controls should be listened from
  39055. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39056. */
  39057. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39058. /** @hidden */
  39059. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39060. /**
  39061. * Update the current camera state depending on the inputs that have been used this frame.
  39062. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39063. */
  39064. checkInputs(): void;
  39065. /**
  39066. * Detach the current controls from the specified dom element.
  39067. * @param element Defines the element to stop listening the inputs from
  39068. */
  39069. detachControl(element: Nullable<HTMLElement>): void;
  39070. /**
  39071. * Gets the class name of the current intput.
  39072. * @returns the class name
  39073. */
  39074. getClassName(): string;
  39075. /**
  39076. * Get the friendly name associated with the input class.
  39077. * @returns the input friendly name
  39078. */
  39079. getSimpleName(): string;
  39080. }
  39081. }
  39082. declare module BABYLON {
  39083. /**
  39084. * Listen to mouse events to control the camera.
  39085. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39086. */
  39087. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39088. /**
  39089. * Defines the camera the input is attached to.
  39090. */
  39091. camera: FlyCamera;
  39092. /**
  39093. * Defines if touch is enabled. (Default is true.)
  39094. */
  39095. touchEnabled: boolean;
  39096. /**
  39097. * Defines the buttons associated with the input to handle camera rotation.
  39098. */
  39099. buttons: number[];
  39100. /**
  39101. * Assign buttons for Yaw control.
  39102. */
  39103. buttonsYaw: number[];
  39104. /**
  39105. * Assign buttons for Pitch control.
  39106. */
  39107. buttonsPitch: number[];
  39108. /**
  39109. * Assign buttons for Roll control.
  39110. */
  39111. buttonsRoll: number[];
  39112. /**
  39113. * Detect if any button is being pressed while mouse is moved.
  39114. * -1 = Mouse locked.
  39115. * 0 = Left button.
  39116. * 1 = Middle Button.
  39117. * 2 = Right Button.
  39118. */
  39119. activeButton: number;
  39120. /**
  39121. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39122. * Higher values reduce its sensitivity.
  39123. */
  39124. angularSensibility: number;
  39125. private _mousemoveCallback;
  39126. private _observer;
  39127. private _rollObserver;
  39128. private previousPosition;
  39129. private noPreventDefault;
  39130. private element;
  39131. /**
  39132. * Listen to mouse events to control the camera.
  39133. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39134. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39135. */
  39136. constructor(touchEnabled?: boolean);
  39137. /**
  39138. * Attach the mouse control to the HTML DOM element.
  39139. * @param element Defines the element that listens to the input events.
  39140. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39141. */
  39142. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39143. /**
  39144. * Detach the current controls from the specified dom element.
  39145. * @param element Defines the element to stop listening the inputs from
  39146. */
  39147. detachControl(element: Nullable<HTMLElement>): void;
  39148. /**
  39149. * Gets the class name of the current input.
  39150. * @returns the class name.
  39151. */
  39152. getClassName(): string;
  39153. /**
  39154. * Get the friendly name associated with the input class.
  39155. * @returns the input's friendly name.
  39156. */
  39157. getSimpleName(): string;
  39158. private _pointerInput;
  39159. private _onMouseMove;
  39160. /**
  39161. * Rotate camera by mouse offset.
  39162. */
  39163. private rotateCamera;
  39164. }
  39165. }
  39166. declare module BABYLON {
  39167. /**
  39168. * Default Inputs manager for the FlyCamera.
  39169. * It groups all the default supported inputs for ease of use.
  39170. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39171. */
  39172. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39173. /**
  39174. * Instantiates a new FlyCameraInputsManager.
  39175. * @param camera Defines the camera the inputs belong to.
  39176. */
  39177. constructor(camera: FlyCamera);
  39178. /**
  39179. * Add keyboard input support to the input manager.
  39180. * @returns the new FlyCameraKeyboardMoveInput().
  39181. */
  39182. addKeyboard(): FlyCameraInputsManager;
  39183. /**
  39184. * Add mouse input support to the input manager.
  39185. * @param touchEnabled Enable touch screen support.
  39186. * @returns the new FlyCameraMouseInput().
  39187. */
  39188. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39189. }
  39190. }
  39191. declare module BABYLON {
  39192. /**
  39193. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39194. * such as in a 3D Space Shooter or a Flight Simulator.
  39195. */
  39196. export class FlyCamera extends TargetCamera {
  39197. /**
  39198. * Define the collision ellipsoid of the camera.
  39199. * This is helpful for simulating a camera body, like a player's body.
  39200. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39201. */
  39202. ellipsoid: Vector3;
  39203. /**
  39204. * Define an offset for the position of the ellipsoid around the camera.
  39205. * This can be helpful if the camera is attached away from the player's body center,
  39206. * such as at its head.
  39207. */
  39208. ellipsoidOffset: Vector3;
  39209. /**
  39210. * Enable or disable collisions of the camera with the rest of the scene objects.
  39211. */
  39212. checkCollisions: boolean;
  39213. /**
  39214. * Enable or disable gravity on the camera.
  39215. */
  39216. applyGravity: boolean;
  39217. /**
  39218. * Define the current direction the camera is moving to.
  39219. */
  39220. cameraDirection: Vector3;
  39221. /**
  39222. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39223. * This overrides and empties cameraRotation.
  39224. */
  39225. rotationQuaternion: Quaternion;
  39226. /**
  39227. * Track Roll to maintain the wanted Rolling when looking around.
  39228. */
  39229. _trackRoll: number;
  39230. /**
  39231. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39232. */
  39233. rollCorrect: number;
  39234. /**
  39235. * Mimic a banked turn, Rolling the camera when Yawing.
  39236. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39237. */
  39238. bankedTurn: boolean;
  39239. /**
  39240. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39241. */
  39242. bankedTurnLimit: number;
  39243. /**
  39244. * Value of 0 disables the banked Roll.
  39245. * Value of 1 is equal to the Yaw angle in radians.
  39246. */
  39247. bankedTurnMultiplier: number;
  39248. /**
  39249. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39250. */
  39251. inputs: FlyCameraInputsManager;
  39252. /**
  39253. * Gets the input sensibility for mouse input.
  39254. * Higher values reduce sensitivity.
  39255. */
  39256. /**
  39257. * Sets the input sensibility for a mouse input.
  39258. * Higher values reduce sensitivity.
  39259. */
  39260. angularSensibility: number;
  39261. /**
  39262. * Get the keys for camera movement forward.
  39263. */
  39264. /**
  39265. * Set the keys for camera movement forward.
  39266. */
  39267. keysForward: number[];
  39268. /**
  39269. * Get the keys for camera movement backward.
  39270. */
  39271. keysBackward: number[];
  39272. /**
  39273. * Get the keys for camera movement up.
  39274. */
  39275. /**
  39276. * Set the keys for camera movement up.
  39277. */
  39278. keysUp: number[];
  39279. /**
  39280. * Get the keys for camera movement down.
  39281. */
  39282. /**
  39283. * Set the keys for camera movement down.
  39284. */
  39285. keysDown: number[];
  39286. /**
  39287. * Get the keys for camera movement left.
  39288. */
  39289. /**
  39290. * Set the keys for camera movement left.
  39291. */
  39292. keysLeft: number[];
  39293. /**
  39294. * Set the keys for camera movement right.
  39295. */
  39296. /**
  39297. * Set the keys for camera movement right.
  39298. */
  39299. keysRight: number[];
  39300. /**
  39301. * Event raised when the camera collides with a mesh in the scene.
  39302. */
  39303. onCollide: (collidedMesh: AbstractMesh) => void;
  39304. private _collider;
  39305. private _needMoveForGravity;
  39306. private _oldPosition;
  39307. private _diffPosition;
  39308. private _newPosition;
  39309. /** @hidden */
  39310. _localDirection: Vector3;
  39311. /** @hidden */
  39312. _transformedDirection: Vector3;
  39313. /**
  39314. * Instantiates a FlyCamera.
  39315. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39316. * such as in a 3D Space Shooter or a Flight Simulator.
  39317. * @param name Define the name of the camera in the scene.
  39318. * @param position Define the starting position of the camera in the scene.
  39319. * @param scene Define the scene the camera belongs to.
  39320. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39321. */
  39322. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39323. /**
  39324. * Attach a control to the HTML DOM element.
  39325. * @param element Defines the element that listens to the input events.
  39326. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39327. */
  39328. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39329. /**
  39330. * Detach a control from the HTML DOM element.
  39331. * The camera will stop reacting to that input.
  39332. * @param element Defines the element that listens to the input events.
  39333. */
  39334. detachControl(element: HTMLElement): void;
  39335. private _collisionMask;
  39336. /**
  39337. * Get the mask that the camera ignores in collision events.
  39338. */
  39339. /**
  39340. * Set the mask that the camera ignores in collision events.
  39341. */
  39342. collisionMask: number;
  39343. /** @hidden */
  39344. _collideWithWorld(displacement: Vector3): void;
  39345. /** @hidden */
  39346. private _onCollisionPositionChange;
  39347. /** @hidden */
  39348. _checkInputs(): void;
  39349. /** @hidden */
  39350. _decideIfNeedsToMove(): boolean;
  39351. /** @hidden */
  39352. _updatePosition(): void;
  39353. /**
  39354. * Restore the Roll to its target value at the rate specified.
  39355. * @param rate - Higher means slower restoring.
  39356. * @hidden
  39357. */
  39358. restoreRoll(rate: number): void;
  39359. /**
  39360. * Destroy the camera and release the current resources held by it.
  39361. */
  39362. dispose(): void;
  39363. /**
  39364. * Get the current object class name.
  39365. * @returns the class name.
  39366. */
  39367. getClassName(): string;
  39368. }
  39369. }
  39370. declare module BABYLON {
  39371. /**
  39372. * Listen to keyboard events to control the camera.
  39373. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39374. */
  39375. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39376. /**
  39377. * Defines the camera the input is attached to.
  39378. */
  39379. camera: FlyCamera;
  39380. /**
  39381. * The list of keyboard keys used to control the forward move of the camera.
  39382. */
  39383. keysForward: number[];
  39384. /**
  39385. * The list of keyboard keys used to control the backward move of the camera.
  39386. */
  39387. keysBackward: number[];
  39388. /**
  39389. * The list of keyboard keys used to control the forward move of the camera.
  39390. */
  39391. keysUp: number[];
  39392. /**
  39393. * The list of keyboard keys used to control the backward move of the camera.
  39394. */
  39395. keysDown: number[];
  39396. /**
  39397. * The list of keyboard keys used to control the right strafe move of the camera.
  39398. */
  39399. keysRight: number[];
  39400. /**
  39401. * The list of keyboard keys used to control the left strafe move of the camera.
  39402. */
  39403. keysLeft: number[];
  39404. private _keys;
  39405. private _onCanvasBlurObserver;
  39406. private _onKeyboardObserver;
  39407. private _engine;
  39408. private _scene;
  39409. /**
  39410. * Attach the input controls to a specific dom element to get the input from.
  39411. * @param element Defines the element the controls should be listened from
  39412. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39413. */
  39414. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39415. /**
  39416. * Detach the current controls from the specified dom element.
  39417. * @param element Defines the element to stop listening the inputs from
  39418. */
  39419. detachControl(element: Nullable<HTMLElement>): void;
  39420. /**
  39421. * Gets the class name of the current intput.
  39422. * @returns the class name
  39423. */
  39424. getClassName(): string;
  39425. /** @hidden */
  39426. _onLostFocus(e: FocusEvent): void;
  39427. /**
  39428. * Get the friendly name associated with the input class.
  39429. * @returns the input friendly name
  39430. */
  39431. getSimpleName(): string;
  39432. /**
  39433. * Update the current camera state depending on the inputs that have been used this frame.
  39434. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39435. */
  39436. checkInputs(): void;
  39437. }
  39438. }
  39439. declare module BABYLON {
  39440. /**
  39441. * Manage the mouse wheel inputs to control a follow camera.
  39442. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39443. */
  39444. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39445. /**
  39446. * Defines the camera the input is attached to.
  39447. */
  39448. camera: FollowCamera;
  39449. /**
  39450. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39451. */
  39452. axisControlRadius: boolean;
  39453. /**
  39454. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39455. */
  39456. axisControlHeight: boolean;
  39457. /**
  39458. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39459. */
  39460. axisControlRotation: boolean;
  39461. /**
  39462. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39463. * relation to mouseWheel events.
  39464. */
  39465. wheelPrecision: number;
  39466. /**
  39467. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39468. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39469. */
  39470. wheelDeltaPercentage: number;
  39471. private _wheel;
  39472. private _observer;
  39473. /**
  39474. * Attach the input controls to a specific dom element to get the input from.
  39475. * @param element Defines the element the controls should be listened from
  39476. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39477. */
  39478. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39479. /**
  39480. * Detach the current controls from the specified dom element.
  39481. * @param element Defines the element to stop listening the inputs from
  39482. */
  39483. detachControl(element: Nullable<HTMLElement>): void;
  39484. /**
  39485. * Gets the class name of the current intput.
  39486. * @returns the class name
  39487. */
  39488. getClassName(): string;
  39489. /**
  39490. * Get the friendly name associated with the input class.
  39491. * @returns the input friendly name
  39492. */
  39493. getSimpleName(): string;
  39494. }
  39495. }
  39496. declare module BABYLON {
  39497. /**
  39498. * Manage the pointers inputs to control an follow camera.
  39499. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39500. */
  39501. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39502. /**
  39503. * Defines the camera the input is attached to.
  39504. */
  39505. camera: FollowCamera;
  39506. /**
  39507. * Gets the class name of the current input.
  39508. * @returns the class name
  39509. */
  39510. getClassName(): string;
  39511. /**
  39512. * Defines the pointer angular sensibility along the X axis or how fast is
  39513. * the camera rotating.
  39514. * A negative number will reverse the axis direction.
  39515. */
  39516. angularSensibilityX: number;
  39517. /**
  39518. * Defines the pointer angular sensibility along the Y axis or how fast is
  39519. * the camera rotating.
  39520. * A negative number will reverse the axis direction.
  39521. */
  39522. angularSensibilityY: number;
  39523. /**
  39524. * Defines the pointer pinch precision or how fast is the camera zooming.
  39525. * A negative number will reverse the axis direction.
  39526. */
  39527. pinchPrecision: number;
  39528. /**
  39529. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39530. * from 0.
  39531. * It defines the percentage of current camera.radius to use as delta when
  39532. * pinch zoom is used.
  39533. */
  39534. pinchDeltaPercentage: number;
  39535. /**
  39536. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39537. */
  39538. axisXControlRadius: boolean;
  39539. /**
  39540. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39541. */
  39542. axisXControlHeight: boolean;
  39543. /**
  39544. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39545. */
  39546. axisXControlRotation: boolean;
  39547. /**
  39548. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39549. */
  39550. axisYControlRadius: boolean;
  39551. /**
  39552. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39553. */
  39554. axisYControlHeight: boolean;
  39555. /**
  39556. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39557. */
  39558. axisYControlRotation: boolean;
  39559. /**
  39560. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39561. */
  39562. axisPinchControlRadius: boolean;
  39563. /**
  39564. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39565. */
  39566. axisPinchControlHeight: boolean;
  39567. /**
  39568. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39569. */
  39570. axisPinchControlRotation: boolean;
  39571. /**
  39572. * Log error messages if basic misconfiguration has occurred.
  39573. */
  39574. warningEnable: boolean;
  39575. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39576. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39577. private _warningCounter;
  39578. private _warning;
  39579. }
  39580. }
  39581. declare module BABYLON {
  39582. /**
  39583. * Default Inputs manager for the FollowCamera.
  39584. * It groups all the default supported inputs for ease of use.
  39585. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39586. */
  39587. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39588. /**
  39589. * Instantiates a new FollowCameraInputsManager.
  39590. * @param camera Defines the camera the inputs belong to
  39591. */
  39592. constructor(camera: FollowCamera);
  39593. /**
  39594. * Add keyboard input support to the input manager.
  39595. * @returns the current input manager
  39596. */
  39597. addKeyboard(): FollowCameraInputsManager;
  39598. /**
  39599. * Add mouse wheel input support to the input manager.
  39600. * @returns the current input manager
  39601. */
  39602. addMouseWheel(): FollowCameraInputsManager;
  39603. /**
  39604. * Add pointers input support to the input manager.
  39605. * @returns the current input manager
  39606. */
  39607. addPointers(): FollowCameraInputsManager;
  39608. /**
  39609. * Add orientation input support to the input manager.
  39610. * @returns the current input manager
  39611. */
  39612. addVRDeviceOrientation(): FollowCameraInputsManager;
  39613. }
  39614. }
  39615. declare module BABYLON {
  39616. /**
  39617. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39618. * an arc rotate version arcFollowCamera are available.
  39619. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39620. */
  39621. export class FollowCamera extends TargetCamera {
  39622. /**
  39623. * Distance the follow camera should follow an object at
  39624. */
  39625. radius: number;
  39626. /**
  39627. * Minimum allowed distance of the camera to the axis of rotation
  39628. * (The camera can not get closer).
  39629. * This can help limiting how the Camera is able to move in the scene.
  39630. */
  39631. lowerRadiusLimit: Nullable<number>;
  39632. /**
  39633. * Maximum allowed distance of the camera to the axis of rotation
  39634. * (The camera can not get further).
  39635. * This can help limiting how the Camera is able to move in the scene.
  39636. */
  39637. upperRadiusLimit: Nullable<number>;
  39638. /**
  39639. * Define a rotation offset between the camera and the object it follows
  39640. */
  39641. rotationOffset: number;
  39642. /**
  39643. * Minimum allowed angle to camera position relative to target object.
  39644. * This can help limiting how the Camera is able to move in the scene.
  39645. */
  39646. lowerRotationOffsetLimit: Nullable<number>;
  39647. /**
  39648. * Maximum allowed angle to camera position relative to target object.
  39649. * This can help limiting how the Camera is able to move in the scene.
  39650. */
  39651. upperRotationOffsetLimit: Nullable<number>;
  39652. /**
  39653. * Define a height offset between the camera and the object it follows.
  39654. * It can help following an object from the top (like a car chaing a plane)
  39655. */
  39656. heightOffset: number;
  39657. /**
  39658. * Minimum allowed height of camera position relative to target object.
  39659. * This can help limiting how the Camera is able to move in the scene.
  39660. */
  39661. lowerHeightOffsetLimit: Nullable<number>;
  39662. /**
  39663. * Maximum allowed height of camera position relative to target object.
  39664. * This can help limiting how the Camera is able to move in the scene.
  39665. */
  39666. upperHeightOffsetLimit: Nullable<number>;
  39667. /**
  39668. * Define how fast the camera can accelerate to follow it s target.
  39669. */
  39670. cameraAcceleration: number;
  39671. /**
  39672. * Define the speed limit of the camera following an object.
  39673. */
  39674. maxCameraSpeed: number;
  39675. /**
  39676. * Define the target of the camera.
  39677. */
  39678. lockedTarget: Nullable<AbstractMesh>;
  39679. /**
  39680. * Defines the input associated with the camera.
  39681. */
  39682. inputs: FollowCameraInputsManager;
  39683. /**
  39684. * Instantiates the follow camera.
  39685. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39686. * @param name Define the name of the camera in the scene
  39687. * @param position Define the position of the camera
  39688. * @param scene Define the scene the camera belong to
  39689. * @param lockedTarget Define the target of the camera
  39690. */
  39691. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39692. private _follow;
  39693. /**
  39694. * Attached controls to the current camera.
  39695. * @param element Defines the element the controls should be listened from
  39696. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39697. */
  39698. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39699. /**
  39700. * Detach the current controls from the camera.
  39701. * The camera will stop reacting to inputs.
  39702. * @param element Defines the element to stop listening the inputs from
  39703. */
  39704. detachControl(element: HTMLElement): void;
  39705. /** @hidden */
  39706. _checkInputs(): void;
  39707. private _checkLimits;
  39708. /**
  39709. * Gets the camera class name.
  39710. * @returns the class name
  39711. */
  39712. getClassName(): string;
  39713. }
  39714. /**
  39715. * Arc Rotate version of the follow camera.
  39716. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39717. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39718. */
  39719. export class ArcFollowCamera extends TargetCamera {
  39720. /** The longitudinal angle of the camera */
  39721. alpha: number;
  39722. /** The latitudinal angle of the camera */
  39723. beta: number;
  39724. /** The radius of the camera from its target */
  39725. radius: number;
  39726. /** Define the camera target (the messh it should follow) */
  39727. target: Nullable<AbstractMesh>;
  39728. private _cartesianCoordinates;
  39729. /**
  39730. * Instantiates a new ArcFollowCamera
  39731. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39732. * @param name Define the name of the camera
  39733. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39734. * @param beta Define the rotation angle of the camera around the elevation axis
  39735. * @param radius Define the radius of the camera from its target point
  39736. * @param target Define the target of the camera
  39737. * @param scene Define the scene the camera belongs to
  39738. */
  39739. constructor(name: string,
  39740. /** The longitudinal angle of the camera */
  39741. alpha: number,
  39742. /** The latitudinal angle of the camera */
  39743. beta: number,
  39744. /** The radius of the camera from its target */
  39745. radius: number,
  39746. /** Define the camera target (the messh it should follow) */
  39747. target: Nullable<AbstractMesh>, scene: Scene);
  39748. private _follow;
  39749. /** @hidden */
  39750. _checkInputs(): void;
  39751. /**
  39752. * Returns the class name of the object.
  39753. * It is mostly used internally for serialization purposes.
  39754. */
  39755. getClassName(): string;
  39756. }
  39757. }
  39758. declare module BABYLON {
  39759. /**
  39760. * Manage the keyboard inputs to control the movement of a follow camera.
  39761. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39762. */
  39763. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39764. /**
  39765. * Defines the camera the input is attached to.
  39766. */
  39767. camera: FollowCamera;
  39768. /**
  39769. * Defines the list of key codes associated with the up action (increase heightOffset)
  39770. */
  39771. keysHeightOffsetIncr: number[];
  39772. /**
  39773. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39774. */
  39775. keysHeightOffsetDecr: number[];
  39776. /**
  39777. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39778. */
  39779. keysHeightOffsetModifierAlt: boolean;
  39780. /**
  39781. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39782. */
  39783. keysHeightOffsetModifierCtrl: boolean;
  39784. /**
  39785. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39786. */
  39787. keysHeightOffsetModifierShift: boolean;
  39788. /**
  39789. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39790. */
  39791. keysRotationOffsetIncr: number[];
  39792. /**
  39793. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39794. */
  39795. keysRotationOffsetDecr: number[];
  39796. /**
  39797. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39798. */
  39799. keysRotationOffsetModifierAlt: boolean;
  39800. /**
  39801. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39802. */
  39803. keysRotationOffsetModifierCtrl: boolean;
  39804. /**
  39805. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39806. */
  39807. keysRotationOffsetModifierShift: boolean;
  39808. /**
  39809. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39810. */
  39811. keysRadiusIncr: number[];
  39812. /**
  39813. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39814. */
  39815. keysRadiusDecr: number[];
  39816. /**
  39817. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39818. */
  39819. keysRadiusModifierAlt: boolean;
  39820. /**
  39821. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39822. */
  39823. keysRadiusModifierCtrl: boolean;
  39824. /**
  39825. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39826. */
  39827. keysRadiusModifierShift: boolean;
  39828. /**
  39829. * Defines the rate of change of heightOffset.
  39830. */
  39831. heightSensibility: number;
  39832. /**
  39833. * Defines the rate of change of rotationOffset.
  39834. */
  39835. rotationSensibility: number;
  39836. /**
  39837. * Defines the rate of change of radius.
  39838. */
  39839. radiusSensibility: number;
  39840. private _keys;
  39841. private _ctrlPressed;
  39842. private _altPressed;
  39843. private _shiftPressed;
  39844. private _onCanvasBlurObserver;
  39845. private _onKeyboardObserver;
  39846. private _engine;
  39847. private _scene;
  39848. /**
  39849. * Attach the input controls to a specific dom element to get the input from.
  39850. * @param element Defines the element the controls should be listened from
  39851. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39852. */
  39853. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39854. /**
  39855. * Detach the current controls from the specified dom element.
  39856. * @param element Defines the element to stop listening the inputs from
  39857. */
  39858. detachControl(element: Nullable<HTMLElement>): void;
  39859. /**
  39860. * Update the current camera state depending on the inputs that have been used this frame.
  39861. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39862. */
  39863. checkInputs(): void;
  39864. /**
  39865. * Gets the class name of the current input.
  39866. * @returns the class name
  39867. */
  39868. getClassName(): string;
  39869. /**
  39870. * Get the friendly name associated with the input class.
  39871. * @returns the input friendly name
  39872. */
  39873. getSimpleName(): string;
  39874. /**
  39875. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39876. * allow modification of the heightOffset value.
  39877. */
  39878. private _modifierHeightOffset;
  39879. /**
  39880. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39881. * allow modification of the rotationOffset value.
  39882. */
  39883. private _modifierRotationOffset;
  39884. /**
  39885. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39886. * allow modification of the radius value.
  39887. */
  39888. private _modifierRadius;
  39889. }
  39890. }
  39891. declare module BABYLON {
  39892. interface FreeCameraInputsManager {
  39893. /**
  39894. * @hidden
  39895. */
  39896. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39897. /**
  39898. * Add orientation input support to the input manager.
  39899. * @returns the current input manager
  39900. */
  39901. addDeviceOrientation(): FreeCameraInputsManager;
  39902. }
  39903. /**
  39904. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39905. * Screen rotation is taken into account.
  39906. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39907. */
  39908. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39909. private _camera;
  39910. private _screenOrientationAngle;
  39911. private _constantTranform;
  39912. private _screenQuaternion;
  39913. private _alpha;
  39914. private _beta;
  39915. private _gamma;
  39916. /**
  39917. * Can be used to detect if a device orientation sensor is available on a device
  39918. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39919. * @returns a promise that will resolve on orientation change
  39920. */
  39921. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39922. /**
  39923. * @hidden
  39924. */
  39925. _onDeviceOrientationChangedObservable: Observable<void>;
  39926. /**
  39927. * Instantiates a new input
  39928. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39929. */
  39930. constructor();
  39931. /**
  39932. * Define the camera controlled by the input.
  39933. */
  39934. camera: FreeCamera;
  39935. /**
  39936. * Attach the input controls to a specific dom element to get the input from.
  39937. * @param element Defines the element the controls should be listened from
  39938. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39939. */
  39940. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39941. private _orientationChanged;
  39942. private _deviceOrientation;
  39943. /**
  39944. * Detach the current controls from the specified dom element.
  39945. * @param element Defines the element to stop listening the inputs from
  39946. */
  39947. detachControl(element: Nullable<HTMLElement>): void;
  39948. /**
  39949. * Update the current camera state depending on the inputs that have been used this frame.
  39950. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39951. */
  39952. checkInputs(): void;
  39953. /**
  39954. * Gets the class name of the current intput.
  39955. * @returns the class name
  39956. */
  39957. getClassName(): string;
  39958. /**
  39959. * Get the friendly name associated with the input class.
  39960. * @returns the input friendly name
  39961. */
  39962. getSimpleName(): string;
  39963. }
  39964. }
  39965. declare module BABYLON {
  39966. /**
  39967. * Manage the gamepad inputs to control a free camera.
  39968. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39969. */
  39970. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39971. /**
  39972. * Define the camera the input is attached to.
  39973. */
  39974. camera: FreeCamera;
  39975. /**
  39976. * Define the Gamepad controlling the input
  39977. */
  39978. gamepad: Nullable<Gamepad>;
  39979. /**
  39980. * Defines the gamepad rotation sensiblity.
  39981. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39982. */
  39983. gamepadAngularSensibility: number;
  39984. /**
  39985. * Defines the gamepad move sensiblity.
  39986. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39987. */
  39988. gamepadMoveSensibility: number;
  39989. private _yAxisScale;
  39990. /**
  39991. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39992. */
  39993. invertYAxis: boolean;
  39994. private _onGamepadConnectedObserver;
  39995. private _onGamepadDisconnectedObserver;
  39996. private _cameraTransform;
  39997. private _deltaTransform;
  39998. private _vector3;
  39999. private _vector2;
  40000. /**
  40001. * Attach the input controls to a specific dom element to get the input from.
  40002. * @param element Defines the element the controls should be listened from
  40003. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40004. */
  40005. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40006. /**
  40007. * Detach the current controls from the specified dom element.
  40008. * @param element Defines the element to stop listening the inputs from
  40009. */
  40010. detachControl(element: Nullable<HTMLElement>): void;
  40011. /**
  40012. * Update the current camera state depending on the inputs that have been used this frame.
  40013. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40014. */
  40015. checkInputs(): void;
  40016. /**
  40017. * Gets the class name of the current intput.
  40018. * @returns the class name
  40019. */
  40020. getClassName(): string;
  40021. /**
  40022. * Get the friendly name associated with the input class.
  40023. * @returns the input friendly name
  40024. */
  40025. getSimpleName(): string;
  40026. }
  40027. }
  40028. declare module BABYLON {
  40029. /**
  40030. * Defines the potential axis of a Joystick
  40031. */
  40032. export enum JoystickAxis {
  40033. /** X axis */
  40034. X = 0,
  40035. /** Y axis */
  40036. Y = 1,
  40037. /** Z axis */
  40038. Z = 2
  40039. }
  40040. /**
  40041. * Class used to define virtual joystick (used in touch mode)
  40042. */
  40043. export class VirtualJoystick {
  40044. /**
  40045. * Gets or sets a boolean indicating that left and right values must be inverted
  40046. */
  40047. reverseLeftRight: boolean;
  40048. /**
  40049. * Gets or sets a boolean indicating that up and down values must be inverted
  40050. */
  40051. reverseUpDown: boolean;
  40052. /**
  40053. * Gets the offset value for the position (ie. the change of the position value)
  40054. */
  40055. deltaPosition: Vector3;
  40056. /**
  40057. * Gets a boolean indicating if the virtual joystick was pressed
  40058. */
  40059. pressed: boolean;
  40060. /**
  40061. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40062. */
  40063. static Canvas: Nullable<HTMLCanvasElement>;
  40064. private static _globalJoystickIndex;
  40065. private static vjCanvasContext;
  40066. private static vjCanvasWidth;
  40067. private static vjCanvasHeight;
  40068. private static halfWidth;
  40069. private _action;
  40070. private _axisTargetedByLeftAndRight;
  40071. private _axisTargetedByUpAndDown;
  40072. private _joystickSensibility;
  40073. private _inversedSensibility;
  40074. private _joystickPointerID;
  40075. private _joystickColor;
  40076. private _joystickPointerPos;
  40077. private _joystickPreviousPointerPos;
  40078. private _joystickPointerStartPos;
  40079. private _deltaJoystickVector;
  40080. private _leftJoystick;
  40081. private _touches;
  40082. private _onPointerDownHandlerRef;
  40083. private _onPointerMoveHandlerRef;
  40084. private _onPointerUpHandlerRef;
  40085. private _onResize;
  40086. /**
  40087. * Creates a new virtual joystick
  40088. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40089. */
  40090. constructor(leftJoystick?: boolean);
  40091. /**
  40092. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40093. * @param newJoystickSensibility defines the new sensibility
  40094. */
  40095. setJoystickSensibility(newJoystickSensibility: number): void;
  40096. private _onPointerDown;
  40097. private _onPointerMove;
  40098. private _onPointerUp;
  40099. /**
  40100. * Change the color of the virtual joystick
  40101. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40102. */
  40103. setJoystickColor(newColor: string): void;
  40104. /**
  40105. * Defines a callback to call when the joystick is touched
  40106. * @param action defines the callback
  40107. */
  40108. setActionOnTouch(action: () => any): void;
  40109. /**
  40110. * Defines which axis you'd like to control for left & right
  40111. * @param axis defines the axis to use
  40112. */
  40113. setAxisForLeftRight(axis: JoystickAxis): void;
  40114. /**
  40115. * Defines which axis you'd like to control for up & down
  40116. * @param axis defines the axis to use
  40117. */
  40118. setAxisForUpDown(axis: JoystickAxis): void;
  40119. private _drawVirtualJoystick;
  40120. /**
  40121. * Release internal HTML canvas
  40122. */
  40123. releaseCanvas(): void;
  40124. }
  40125. }
  40126. declare module BABYLON {
  40127. interface FreeCameraInputsManager {
  40128. /**
  40129. * Add virtual joystick input support to the input manager.
  40130. * @returns the current input manager
  40131. */
  40132. addVirtualJoystick(): FreeCameraInputsManager;
  40133. }
  40134. /**
  40135. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40136. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40137. */
  40138. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40139. /**
  40140. * Defines the camera the input is attached to.
  40141. */
  40142. camera: FreeCamera;
  40143. private _leftjoystick;
  40144. private _rightjoystick;
  40145. /**
  40146. * Gets the left stick of the virtual joystick.
  40147. * @returns The virtual Joystick
  40148. */
  40149. getLeftJoystick(): VirtualJoystick;
  40150. /**
  40151. * Gets the right stick of the virtual joystick.
  40152. * @returns The virtual Joystick
  40153. */
  40154. getRightJoystick(): VirtualJoystick;
  40155. /**
  40156. * Update the current camera state depending on the inputs that have been used this frame.
  40157. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40158. */
  40159. checkInputs(): void;
  40160. /**
  40161. * Attach the input controls to a specific dom element to get the input from.
  40162. * @param element Defines the element the controls should be listened from
  40163. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40164. */
  40165. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40166. /**
  40167. * Detach the current controls from the specified dom element.
  40168. * @param element Defines the element to stop listening the inputs from
  40169. */
  40170. detachControl(element: Nullable<HTMLElement>): void;
  40171. /**
  40172. * Gets the class name of the current intput.
  40173. * @returns the class name
  40174. */
  40175. getClassName(): string;
  40176. /**
  40177. * Get the friendly name associated with the input class.
  40178. * @returns the input friendly name
  40179. */
  40180. getSimpleName(): string;
  40181. }
  40182. }
  40183. declare module BABYLON {
  40184. /**
  40185. * This represents a FPS type of camera controlled by touch.
  40186. * This is like a universal camera minus the Gamepad controls.
  40187. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40188. */
  40189. export class TouchCamera extends FreeCamera {
  40190. /**
  40191. * Defines the touch sensibility for rotation.
  40192. * The higher the faster.
  40193. */
  40194. touchAngularSensibility: number;
  40195. /**
  40196. * Defines the touch sensibility for move.
  40197. * The higher the faster.
  40198. */
  40199. touchMoveSensibility: number;
  40200. /**
  40201. * Instantiates a new touch camera.
  40202. * This represents a FPS type of camera controlled by touch.
  40203. * This is like a universal camera minus the Gamepad controls.
  40204. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40205. * @param name Define the name of the camera in the scene
  40206. * @param position Define the start position of the camera in the scene
  40207. * @param scene Define the scene the camera belongs to
  40208. */
  40209. constructor(name: string, position: Vector3, scene: Scene);
  40210. /**
  40211. * Gets the current object class name.
  40212. * @return the class name
  40213. */
  40214. getClassName(): string;
  40215. /** @hidden */
  40216. _setupInputs(): void;
  40217. }
  40218. }
  40219. declare module BABYLON {
  40220. /**
  40221. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40222. * being tilted forward or back and left or right.
  40223. */
  40224. export class DeviceOrientationCamera extends FreeCamera {
  40225. private _initialQuaternion;
  40226. private _quaternionCache;
  40227. private _tmpDragQuaternion;
  40228. private _disablePointerInputWhenUsingDeviceOrientation;
  40229. /**
  40230. * Creates a new device orientation camera
  40231. * @param name The name of the camera
  40232. * @param position The start position camera
  40233. * @param scene The scene the camera belongs to
  40234. */
  40235. constructor(name: string, position: Vector3, scene: Scene);
  40236. /**
  40237. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40238. */
  40239. disablePointerInputWhenUsingDeviceOrientation: boolean;
  40240. private _dragFactor;
  40241. /**
  40242. * Enabled turning on the y axis when the orientation sensor is active
  40243. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40244. */
  40245. enableHorizontalDragging(dragFactor?: number): void;
  40246. /**
  40247. * Gets the current instance class name ("DeviceOrientationCamera").
  40248. * This helps avoiding instanceof at run time.
  40249. * @returns the class name
  40250. */
  40251. getClassName(): string;
  40252. /**
  40253. * @hidden
  40254. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40255. */
  40256. _checkInputs(): void;
  40257. /**
  40258. * Reset the camera to its default orientation on the specified axis only.
  40259. * @param axis The axis to reset
  40260. */
  40261. resetToCurrentRotation(axis?: Axis): void;
  40262. }
  40263. }
  40264. declare module BABYLON {
  40265. /**
  40266. * Defines supported buttons for XBox360 compatible gamepads
  40267. */
  40268. export enum Xbox360Button {
  40269. /** A */
  40270. A = 0,
  40271. /** B */
  40272. B = 1,
  40273. /** X */
  40274. X = 2,
  40275. /** Y */
  40276. Y = 3,
  40277. /** Start */
  40278. Start = 4,
  40279. /** Back */
  40280. Back = 5,
  40281. /** Left button */
  40282. LB = 6,
  40283. /** Right button */
  40284. RB = 7,
  40285. /** Left stick */
  40286. LeftStick = 8,
  40287. /** Right stick */
  40288. RightStick = 9
  40289. }
  40290. /** Defines values for XBox360 DPad */
  40291. export enum Xbox360Dpad {
  40292. /** Up */
  40293. Up = 0,
  40294. /** Down */
  40295. Down = 1,
  40296. /** Left */
  40297. Left = 2,
  40298. /** Right */
  40299. Right = 3
  40300. }
  40301. /**
  40302. * Defines a XBox360 gamepad
  40303. */
  40304. export class Xbox360Pad extends Gamepad {
  40305. private _leftTrigger;
  40306. private _rightTrigger;
  40307. private _onlefttriggerchanged;
  40308. private _onrighttriggerchanged;
  40309. private _onbuttondown;
  40310. private _onbuttonup;
  40311. private _ondpaddown;
  40312. private _ondpadup;
  40313. /** Observable raised when a button is pressed */
  40314. onButtonDownObservable: Observable<Xbox360Button>;
  40315. /** Observable raised when a button is released */
  40316. onButtonUpObservable: Observable<Xbox360Button>;
  40317. /** Observable raised when a pad is pressed */
  40318. onPadDownObservable: Observable<Xbox360Dpad>;
  40319. /** Observable raised when a pad is released */
  40320. onPadUpObservable: Observable<Xbox360Dpad>;
  40321. private _buttonA;
  40322. private _buttonB;
  40323. private _buttonX;
  40324. private _buttonY;
  40325. private _buttonBack;
  40326. private _buttonStart;
  40327. private _buttonLB;
  40328. private _buttonRB;
  40329. private _buttonLeftStick;
  40330. private _buttonRightStick;
  40331. private _dPadUp;
  40332. private _dPadDown;
  40333. private _dPadLeft;
  40334. private _dPadRight;
  40335. private _isXboxOnePad;
  40336. /**
  40337. * Creates a new XBox360 gamepad object
  40338. * @param id defines the id of this gamepad
  40339. * @param index defines its index
  40340. * @param gamepad defines the internal HTML gamepad object
  40341. * @param xboxOne defines if it is a XBox One gamepad
  40342. */
  40343. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40344. /**
  40345. * Defines the callback to call when left trigger is pressed
  40346. * @param callback defines the callback to use
  40347. */
  40348. onlefttriggerchanged(callback: (value: number) => void): void;
  40349. /**
  40350. * Defines the callback to call when right trigger is pressed
  40351. * @param callback defines the callback to use
  40352. */
  40353. onrighttriggerchanged(callback: (value: number) => void): void;
  40354. /**
  40355. * Gets the left trigger value
  40356. */
  40357. /**
  40358. * Sets the left trigger value
  40359. */
  40360. leftTrigger: number;
  40361. /**
  40362. * Gets the right trigger value
  40363. */
  40364. /**
  40365. * Sets the right trigger value
  40366. */
  40367. rightTrigger: number;
  40368. /**
  40369. * Defines the callback to call when a button is pressed
  40370. * @param callback defines the callback to use
  40371. */
  40372. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40373. /**
  40374. * Defines the callback to call when a button is released
  40375. * @param callback defines the callback to use
  40376. */
  40377. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40378. /**
  40379. * Defines the callback to call when a pad is pressed
  40380. * @param callback defines the callback to use
  40381. */
  40382. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40383. /**
  40384. * Defines the callback to call when a pad is released
  40385. * @param callback defines the callback to use
  40386. */
  40387. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40388. private _setButtonValue;
  40389. private _setDPadValue;
  40390. /**
  40391. * Gets the value of the `A` button
  40392. */
  40393. /**
  40394. * Sets the value of the `A` button
  40395. */
  40396. buttonA: number;
  40397. /**
  40398. * Gets the value of the `B` button
  40399. */
  40400. /**
  40401. * Sets the value of the `B` button
  40402. */
  40403. buttonB: number;
  40404. /**
  40405. * Gets the value of the `X` button
  40406. */
  40407. /**
  40408. * Sets the value of the `X` button
  40409. */
  40410. buttonX: number;
  40411. /**
  40412. * Gets the value of the `Y` button
  40413. */
  40414. /**
  40415. * Sets the value of the `Y` button
  40416. */
  40417. buttonY: number;
  40418. /**
  40419. * Gets the value of the `Start` button
  40420. */
  40421. /**
  40422. * Sets the value of the `Start` button
  40423. */
  40424. buttonStart: number;
  40425. /**
  40426. * Gets the value of the `Back` button
  40427. */
  40428. /**
  40429. * Sets the value of the `Back` button
  40430. */
  40431. buttonBack: number;
  40432. /**
  40433. * Gets the value of the `Left` button
  40434. */
  40435. /**
  40436. * Sets the value of the `Left` button
  40437. */
  40438. buttonLB: number;
  40439. /**
  40440. * Gets the value of the `Right` button
  40441. */
  40442. /**
  40443. * Sets the value of the `Right` button
  40444. */
  40445. buttonRB: number;
  40446. /**
  40447. * Gets the value of the Left joystick
  40448. */
  40449. /**
  40450. * Sets the value of the Left joystick
  40451. */
  40452. buttonLeftStick: number;
  40453. /**
  40454. * Gets the value of the Right joystick
  40455. */
  40456. /**
  40457. * Sets the value of the Right joystick
  40458. */
  40459. buttonRightStick: number;
  40460. /**
  40461. * Gets the value of D-pad up
  40462. */
  40463. /**
  40464. * Sets the value of D-pad up
  40465. */
  40466. dPadUp: number;
  40467. /**
  40468. * Gets the value of D-pad down
  40469. */
  40470. /**
  40471. * Sets the value of D-pad down
  40472. */
  40473. dPadDown: number;
  40474. /**
  40475. * Gets the value of D-pad left
  40476. */
  40477. /**
  40478. * Sets the value of D-pad left
  40479. */
  40480. dPadLeft: number;
  40481. /**
  40482. * Gets the value of D-pad right
  40483. */
  40484. /**
  40485. * Sets the value of D-pad right
  40486. */
  40487. dPadRight: number;
  40488. /**
  40489. * Force the gamepad to synchronize with device values
  40490. */
  40491. update(): void;
  40492. /**
  40493. * Disposes the gamepad
  40494. */
  40495. dispose(): void;
  40496. }
  40497. }
  40498. declare module BABYLON {
  40499. /**
  40500. * Defines supported buttons for DualShock compatible gamepads
  40501. */
  40502. export enum DualShockButton {
  40503. /** Cross */
  40504. Cross = 0,
  40505. /** Circle */
  40506. Circle = 1,
  40507. /** Square */
  40508. Square = 2,
  40509. /** Triangle */
  40510. Triangle = 3,
  40511. /** Options */
  40512. Options = 4,
  40513. /** Share */
  40514. Share = 5,
  40515. /** L1 */
  40516. L1 = 6,
  40517. /** R1 */
  40518. R1 = 7,
  40519. /** Left stick */
  40520. LeftStick = 8,
  40521. /** Right stick */
  40522. RightStick = 9
  40523. }
  40524. /** Defines values for DualShock DPad */
  40525. export enum DualShockDpad {
  40526. /** Up */
  40527. Up = 0,
  40528. /** Down */
  40529. Down = 1,
  40530. /** Left */
  40531. Left = 2,
  40532. /** Right */
  40533. Right = 3
  40534. }
  40535. /**
  40536. * Defines a DualShock gamepad
  40537. */
  40538. export class DualShockPad extends Gamepad {
  40539. private _leftTrigger;
  40540. private _rightTrigger;
  40541. private _onlefttriggerchanged;
  40542. private _onrighttriggerchanged;
  40543. private _onbuttondown;
  40544. private _onbuttonup;
  40545. private _ondpaddown;
  40546. private _ondpadup;
  40547. /** Observable raised when a button is pressed */
  40548. onButtonDownObservable: Observable<DualShockButton>;
  40549. /** Observable raised when a button is released */
  40550. onButtonUpObservable: Observable<DualShockButton>;
  40551. /** Observable raised when a pad is pressed */
  40552. onPadDownObservable: Observable<DualShockDpad>;
  40553. /** Observable raised when a pad is released */
  40554. onPadUpObservable: Observable<DualShockDpad>;
  40555. private _buttonCross;
  40556. private _buttonCircle;
  40557. private _buttonSquare;
  40558. private _buttonTriangle;
  40559. private _buttonShare;
  40560. private _buttonOptions;
  40561. private _buttonL1;
  40562. private _buttonR1;
  40563. private _buttonLeftStick;
  40564. private _buttonRightStick;
  40565. private _dPadUp;
  40566. private _dPadDown;
  40567. private _dPadLeft;
  40568. private _dPadRight;
  40569. /**
  40570. * Creates a new DualShock gamepad object
  40571. * @param id defines the id of this gamepad
  40572. * @param index defines its index
  40573. * @param gamepad defines the internal HTML gamepad object
  40574. */
  40575. constructor(id: string, index: number, gamepad: any);
  40576. /**
  40577. * Defines the callback to call when left trigger is pressed
  40578. * @param callback defines the callback to use
  40579. */
  40580. onlefttriggerchanged(callback: (value: number) => void): void;
  40581. /**
  40582. * Defines the callback to call when right trigger is pressed
  40583. * @param callback defines the callback to use
  40584. */
  40585. onrighttriggerchanged(callback: (value: number) => void): void;
  40586. /**
  40587. * Gets the left trigger value
  40588. */
  40589. /**
  40590. * Sets the left trigger value
  40591. */
  40592. leftTrigger: number;
  40593. /**
  40594. * Gets the right trigger value
  40595. */
  40596. /**
  40597. * Sets the right trigger value
  40598. */
  40599. rightTrigger: number;
  40600. /**
  40601. * Defines the callback to call when a button is pressed
  40602. * @param callback defines the callback to use
  40603. */
  40604. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40605. /**
  40606. * Defines the callback to call when a button is released
  40607. * @param callback defines the callback to use
  40608. */
  40609. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40610. /**
  40611. * Defines the callback to call when a pad is pressed
  40612. * @param callback defines the callback to use
  40613. */
  40614. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40615. /**
  40616. * Defines the callback to call when a pad is released
  40617. * @param callback defines the callback to use
  40618. */
  40619. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40620. private _setButtonValue;
  40621. private _setDPadValue;
  40622. /**
  40623. * Gets the value of the `Cross` button
  40624. */
  40625. /**
  40626. * Sets the value of the `Cross` button
  40627. */
  40628. buttonCross: number;
  40629. /**
  40630. * Gets the value of the `Circle` button
  40631. */
  40632. /**
  40633. * Sets the value of the `Circle` button
  40634. */
  40635. buttonCircle: number;
  40636. /**
  40637. * Gets the value of the `Square` button
  40638. */
  40639. /**
  40640. * Sets the value of the `Square` button
  40641. */
  40642. buttonSquare: number;
  40643. /**
  40644. * Gets the value of the `Triangle` button
  40645. */
  40646. /**
  40647. * Sets the value of the `Triangle` button
  40648. */
  40649. buttonTriangle: number;
  40650. /**
  40651. * Gets the value of the `Options` button
  40652. */
  40653. /**
  40654. * Sets the value of the `Options` button
  40655. */
  40656. buttonOptions: number;
  40657. /**
  40658. * Gets the value of the `Share` button
  40659. */
  40660. /**
  40661. * Sets the value of the `Share` button
  40662. */
  40663. buttonShare: number;
  40664. /**
  40665. * Gets the value of the `L1` button
  40666. */
  40667. /**
  40668. * Sets the value of the `L1` button
  40669. */
  40670. buttonL1: number;
  40671. /**
  40672. * Gets the value of the `R1` button
  40673. */
  40674. /**
  40675. * Sets the value of the `R1` button
  40676. */
  40677. buttonR1: number;
  40678. /**
  40679. * Gets the value of the Left joystick
  40680. */
  40681. /**
  40682. * Sets the value of the Left joystick
  40683. */
  40684. buttonLeftStick: number;
  40685. /**
  40686. * Gets the value of the Right joystick
  40687. */
  40688. /**
  40689. * Sets the value of the Right joystick
  40690. */
  40691. buttonRightStick: number;
  40692. /**
  40693. * Gets the value of D-pad up
  40694. */
  40695. /**
  40696. * Sets the value of D-pad up
  40697. */
  40698. dPadUp: number;
  40699. /**
  40700. * Gets the value of D-pad down
  40701. */
  40702. /**
  40703. * Sets the value of D-pad down
  40704. */
  40705. dPadDown: number;
  40706. /**
  40707. * Gets the value of D-pad left
  40708. */
  40709. /**
  40710. * Sets the value of D-pad left
  40711. */
  40712. dPadLeft: number;
  40713. /**
  40714. * Gets the value of D-pad right
  40715. */
  40716. /**
  40717. * Sets the value of D-pad right
  40718. */
  40719. dPadRight: number;
  40720. /**
  40721. * Force the gamepad to synchronize with device values
  40722. */
  40723. update(): void;
  40724. /**
  40725. * Disposes the gamepad
  40726. */
  40727. dispose(): void;
  40728. }
  40729. }
  40730. declare module BABYLON {
  40731. /**
  40732. * Manager for handling gamepads
  40733. */
  40734. export class GamepadManager {
  40735. private _scene?;
  40736. private _babylonGamepads;
  40737. private _oneGamepadConnected;
  40738. /** @hidden */
  40739. _isMonitoring: boolean;
  40740. private _gamepadEventSupported;
  40741. private _gamepadSupport;
  40742. /**
  40743. * observable to be triggered when the gamepad controller has been connected
  40744. */
  40745. onGamepadConnectedObservable: Observable<Gamepad>;
  40746. /**
  40747. * observable to be triggered when the gamepad controller has been disconnected
  40748. */
  40749. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40750. private _onGamepadConnectedEvent;
  40751. private _onGamepadDisconnectedEvent;
  40752. /**
  40753. * Initializes the gamepad manager
  40754. * @param _scene BabylonJS scene
  40755. */
  40756. constructor(_scene?: Scene | undefined);
  40757. /**
  40758. * The gamepads in the game pad manager
  40759. */
  40760. readonly gamepads: Gamepad[];
  40761. /**
  40762. * Get the gamepad controllers based on type
  40763. * @param type The type of gamepad controller
  40764. * @returns Nullable gamepad
  40765. */
  40766. getGamepadByType(type?: number): Nullable<Gamepad>;
  40767. /**
  40768. * Disposes the gamepad manager
  40769. */
  40770. dispose(): void;
  40771. private _addNewGamepad;
  40772. private _startMonitoringGamepads;
  40773. private _stopMonitoringGamepads;
  40774. /** @hidden */
  40775. _checkGamepadsStatus(): void;
  40776. private _updateGamepadObjects;
  40777. }
  40778. }
  40779. declare module BABYLON {
  40780. interface Scene {
  40781. /** @hidden */
  40782. _gamepadManager: Nullable<GamepadManager>;
  40783. /**
  40784. * Gets the gamepad manager associated with the scene
  40785. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40786. */
  40787. gamepadManager: GamepadManager;
  40788. }
  40789. /**
  40790. * Interface representing a free camera inputs manager
  40791. */
  40792. interface FreeCameraInputsManager {
  40793. /**
  40794. * Adds gamepad input support to the FreeCameraInputsManager.
  40795. * @returns the FreeCameraInputsManager
  40796. */
  40797. addGamepad(): FreeCameraInputsManager;
  40798. }
  40799. /**
  40800. * Interface representing an arc rotate camera inputs manager
  40801. */
  40802. interface ArcRotateCameraInputsManager {
  40803. /**
  40804. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40805. * @returns the camera inputs manager
  40806. */
  40807. addGamepad(): ArcRotateCameraInputsManager;
  40808. }
  40809. /**
  40810. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40811. */
  40812. export class GamepadSystemSceneComponent implements ISceneComponent {
  40813. /**
  40814. * The component name helpfull to identify the component in the list of scene components.
  40815. */
  40816. readonly name: string;
  40817. /**
  40818. * The scene the component belongs to.
  40819. */
  40820. scene: Scene;
  40821. /**
  40822. * Creates a new instance of the component for the given scene
  40823. * @param scene Defines the scene to register the component in
  40824. */
  40825. constructor(scene: Scene);
  40826. /**
  40827. * Registers the component in a given scene
  40828. */
  40829. register(): void;
  40830. /**
  40831. * Rebuilds the elements related to this component in case of
  40832. * context lost for instance.
  40833. */
  40834. rebuild(): void;
  40835. /**
  40836. * Disposes the component and the associated ressources
  40837. */
  40838. dispose(): void;
  40839. private _beforeCameraUpdate;
  40840. }
  40841. }
  40842. declare module BABYLON {
  40843. /**
  40844. * 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,
  40845. * which still works and will still be found in many Playgrounds.
  40846. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40847. */
  40848. export class UniversalCamera extends TouchCamera {
  40849. /**
  40850. * Defines the gamepad rotation sensiblity.
  40851. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40852. */
  40853. gamepadAngularSensibility: number;
  40854. /**
  40855. * Defines the gamepad move sensiblity.
  40856. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40857. */
  40858. gamepadMoveSensibility: number;
  40859. /**
  40860. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  40861. * which still works and will still be found in many Playgrounds.
  40862. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40863. * @param name Define the name of the camera in the scene
  40864. * @param position Define the start position of the camera in the scene
  40865. * @param scene Define the scene the camera belongs to
  40866. */
  40867. constructor(name: string, position: Vector3, scene: Scene);
  40868. /**
  40869. * Gets the current object class name.
  40870. * @return the class name
  40871. */
  40872. getClassName(): string;
  40873. }
  40874. }
  40875. declare module BABYLON {
  40876. /**
  40877. * This represents a FPS type of camera. This is only here for back compat purpose.
  40878. * Please use the UniversalCamera instead as both are identical.
  40879. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40880. */
  40881. export class GamepadCamera extends UniversalCamera {
  40882. /**
  40883. * Instantiates a new Gamepad Camera
  40884. * This represents a FPS type of camera. This is only here for back compat purpose.
  40885. * Please use the UniversalCamera instead as both are identical.
  40886. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40887. * @param name Define the name of the camera in the scene
  40888. * @param position Define the start position of the camera in the scene
  40889. * @param scene Define the scene the camera belongs to
  40890. */
  40891. constructor(name: string, position: Vector3, scene: Scene);
  40892. /**
  40893. * Gets the current object class name.
  40894. * @return the class name
  40895. */
  40896. getClassName(): string;
  40897. }
  40898. }
  40899. declare module BABYLON {
  40900. /** @hidden */
  40901. export var passPixelShader: {
  40902. name: string;
  40903. shader: string;
  40904. };
  40905. }
  40906. declare module BABYLON {
  40907. /** @hidden */
  40908. export var passCubePixelShader: {
  40909. name: string;
  40910. shader: string;
  40911. };
  40912. }
  40913. declare module BABYLON {
  40914. /**
  40915. * PassPostProcess which produces an output the same as it's input
  40916. */
  40917. export class PassPostProcess extends PostProcess {
  40918. /**
  40919. * Creates the PassPostProcess
  40920. * @param name The name of the effect.
  40921. * @param options The required width/height ratio to downsize to before computing the render pass.
  40922. * @param camera The camera to apply the render pass to.
  40923. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40924. * @param engine The engine which the post process will be applied. (default: current engine)
  40925. * @param reusable If the post process can be reused on the same frame. (default: false)
  40926. * @param textureType The type of texture to be used when performing the post processing.
  40927. * @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)
  40928. */
  40929. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40930. }
  40931. /**
  40932. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40933. */
  40934. export class PassCubePostProcess extends PostProcess {
  40935. private _face;
  40936. /**
  40937. * Gets or sets the cube face to display.
  40938. * * 0 is +X
  40939. * * 1 is -X
  40940. * * 2 is +Y
  40941. * * 3 is -Y
  40942. * * 4 is +Z
  40943. * * 5 is -Z
  40944. */
  40945. face: number;
  40946. /**
  40947. * Creates the PassCubePostProcess
  40948. * @param name The name of the effect.
  40949. * @param options The required width/height ratio to downsize to before computing the render pass.
  40950. * @param camera The camera to apply the render pass to.
  40951. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40952. * @param engine The engine which the post process will be applied. (default: current engine)
  40953. * @param reusable If the post process can be reused on the same frame. (default: false)
  40954. * @param textureType The type of texture to be used when performing the post processing.
  40955. * @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)
  40956. */
  40957. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40958. }
  40959. }
  40960. declare module BABYLON {
  40961. /** @hidden */
  40962. export var anaglyphPixelShader: {
  40963. name: string;
  40964. shader: string;
  40965. };
  40966. }
  40967. declare module BABYLON {
  40968. /**
  40969. * Postprocess used to generate anaglyphic rendering
  40970. */
  40971. export class AnaglyphPostProcess extends PostProcess {
  40972. private _passedProcess;
  40973. /**
  40974. * Creates a new AnaglyphPostProcess
  40975. * @param name defines postprocess name
  40976. * @param options defines creation options or target ratio scale
  40977. * @param rigCameras defines cameras using this postprocess
  40978. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40979. * @param engine defines hosting engine
  40980. * @param reusable defines if the postprocess will be reused multiple times per frame
  40981. */
  40982. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40983. }
  40984. }
  40985. declare module BABYLON {
  40986. /**
  40987. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40988. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40989. */
  40990. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40991. /**
  40992. * Creates a new AnaglyphArcRotateCamera
  40993. * @param name defines camera name
  40994. * @param alpha defines alpha angle (in radians)
  40995. * @param beta defines beta angle (in radians)
  40996. * @param radius defines radius
  40997. * @param target defines camera target
  40998. * @param interaxialDistance defines distance between each color axis
  40999. * @param scene defines the hosting scene
  41000. */
  41001. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41002. /**
  41003. * Gets camera class name
  41004. * @returns AnaglyphArcRotateCamera
  41005. */
  41006. getClassName(): string;
  41007. }
  41008. }
  41009. declare module BABYLON {
  41010. /**
  41011. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41012. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41013. */
  41014. export class AnaglyphFreeCamera extends FreeCamera {
  41015. /**
  41016. * Creates a new AnaglyphFreeCamera
  41017. * @param name defines camera name
  41018. * @param position defines initial position
  41019. * @param interaxialDistance defines distance between each color axis
  41020. * @param scene defines the hosting scene
  41021. */
  41022. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41023. /**
  41024. * Gets camera class name
  41025. * @returns AnaglyphFreeCamera
  41026. */
  41027. getClassName(): string;
  41028. }
  41029. }
  41030. declare module BABYLON {
  41031. /**
  41032. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41033. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41034. */
  41035. export class AnaglyphGamepadCamera extends GamepadCamera {
  41036. /**
  41037. * Creates a new AnaglyphGamepadCamera
  41038. * @param name defines camera name
  41039. * @param position defines initial position
  41040. * @param interaxialDistance defines distance between each color axis
  41041. * @param scene defines the hosting scene
  41042. */
  41043. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41044. /**
  41045. * Gets camera class name
  41046. * @returns AnaglyphGamepadCamera
  41047. */
  41048. getClassName(): string;
  41049. }
  41050. }
  41051. declare module BABYLON {
  41052. /**
  41053. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41054. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41055. */
  41056. export class AnaglyphUniversalCamera extends UniversalCamera {
  41057. /**
  41058. * Creates a new AnaglyphUniversalCamera
  41059. * @param name defines camera name
  41060. * @param position defines initial position
  41061. * @param interaxialDistance defines distance between each color axis
  41062. * @param scene defines the hosting scene
  41063. */
  41064. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41065. /**
  41066. * Gets camera class name
  41067. * @returns AnaglyphUniversalCamera
  41068. */
  41069. getClassName(): string;
  41070. }
  41071. }
  41072. declare module BABYLON {
  41073. /** @hidden */
  41074. export var stereoscopicInterlacePixelShader: {
  41075. name: string;
  41076. shader: string;
  41077. };
  41078. }
  41079. declare module BABYLON {
  41080. /**
  41081. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41082. */
  41083. export class StereoscopicInterlacePostProcess extends PostProcess {
  41084. private _stepSize;
  41085. private _passedProcess;
  41086. /**
  41087. * Initializes a StereoscopicInterlacePostProcess
  41088. * @param name The name of the effect.
  41089. * @param rigCameras The rig cameras to be appled to the post process
  41090. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41091. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41092. * @param engine The engine which the post process will be applied. (default: current engine)
  41093. * @param reusable If the post process can be reused on the same frame. (default: false)
  41094. */
  41095. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41096. }
  41097. }
  41098. declare module BABYLON {
  41099. /**
  41100. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41101. * @see http://doc.babylonjs.com/features/cameras
  41102. */
  41103. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41104. /**
  41105. * Creates a new StereoscopicArcRotateCamera
  41106. * @param name defines camera name
  41107. * @param alpha defines alpha angle (in radians)
  41108. * @param beta defines beta angle (in radians)
  41109. * @param radius defines radius
  41110. * @param target defines camera target
  41111. * @param interaxialDistance defines distance between each color axis
  41112. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41113. * @param scene defines the hosting scene
  41114. */
  41115. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41116. /**
  41117. * Gets camera class name
  41118. * @returns StereoscopicArcRotateCamera
  41119. */
  41120. getClassName(): string;
  41121. }
  41122. }
  41123. declare module BABYLON {
  41124. /**
  41125. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41126. * @see http://doc.babylonjs.com/features/cameras
  41127. */
  41128. export class StereoscopicFreeCamera extends FreeCamera {
  41129. /**
  41130. * Creates a new StereoscopicFreeCamera
  41131. * @param name defines camera name
  41132. * @param position defines initial position
  41133. * @param interaxialDistance defines distance between each color axis
  41134. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41135. * @param scene defines the hosting scene
  41136. */
  41137. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41138. /**
  41139. * Gets camera class name
  41140. * @returns StereoscopicFreeCamera
  41141. */
  41142. getClassName(): string;
  41143. }
  41144. }
  41145. declare module BABYLON {
  41146. /**
  41147. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41148. * @see http://doc.babylonjs.com/features/cameras
  41149. */
  41150. export class StereoscopicGamepadCamera extends GamepadCamera {
  41151. /**
  41152. * Creates a new StereoscopicGamepadCamera
  41153. * @param name defines camera name
  41154. * @param position defines initial position
  41155. * @param interaxialDistance defines distance between each color axis
  41156. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41157. * @param scene defines the hosting scene
  41158. */
  41159. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41160. /**
  41161. * Gets camera class name
  41162. * @returns StereoscopicGamepadCamera
  41163. */
  41164. getClassName(): string;
  41165. }
  41166. }
  41167. declare module BABYLON {
  41168. /**
  41169. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41170. * @see http://doc.babylonjs.com/features/cameras
  41171. */
  41172. export class StereoscopicUniversalCamera extends UniversalCamera {
  41173. /**
  41174. * Creates a new StereoscopicUniversalCamera
  41175. * @param name defines camera name
  41176. * @param position defines initial position
  41177. * @param interaxialDistance defines distance between each color axis
  41178. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41179. * @param scene defines the hosting scene
  41180. */
  41181. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41182. /**
  41183. * Gets camera class name
  41184. * @returns StereoscopicUniversalCamera
  41185. */
  41186. getClassName(): string;
  41187. }
  41188. }
  41189. declare module BABYLON {
  41190. /**
  41191. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41192. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41193. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41194. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41195. */
  41196. export class VirtualJoysticksCamera extends FreeCamera {
  41197. /**
  41198. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41199. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41200. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41201. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41202. * @param name Define the name of the camera in the scene
  41203. * @param position Define the start position of the camera in the scene
  41204. * @param scene Define the scene the camera belongs to
  41205. */
  41206. constructor(name: string, position: Vector3, scene: Scene);
  41207. /**
  41208. * Gets the current object class name.
  41209. * @return the class name
  41210. */
  41211. getClassName(): string;
  41212. }
  41213. }
  41214. declare module BABYLON {
  41215. /**
  41216. * This represents all the required metrics to create a VR camera.
  41217. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41218. */
  41219. export class VRCameraMetrics {
  41220. /**
  41221. * Define the horizontal resolution off the screen.
  41222. */
  41223. hResolution: number;
  41224. /**
  41225. * Define the vertical resolution off the screen.
  41226. */
  41227. vResolution: number;
  41228. /**
  41229. * Define the horizontal screen size.
  41230. */
  41231. hScreenSize: number;
  41232. /**
  41233. * Define the vertical screen size.
  41234. */
  41235. vScreenSize: number;
  41236. /**
  41237. * Define the vertical screen center position.
  41238. */
  41239. vScreenCenter: number;
  41240. /**
  41241. * Define the distance of the eyes to the screen.
  41242. */
  41243. eyeToScreenDistance: number;
  41244. /**
  41245. * Define the distance between both lenses
  41246. */
  41247. lensSeparationDistance: number;
  41248. /**
  41249. * Define the distance between both viewer's eyes.
  41250. */
  41251. interpupillaryDistance: number;
  41252. /**
  41253. * Define the distortion factor of the VR postprocess.
  41254. * Please, touch with care.
  41255. */
  41256. distortionK: number[];
  41257. /**
  41258. * Define the chromatic aberration correction factors for the VR post process.
  41259. */
  41260. chromaAbCorrection: number[];
  41261. /**
  41262. * Define the scale factor of the post process.
  41263. * The smaller the better but the slower.
  41264. */
  41265. postProcessScaleFactor: number;
  41266. /**
  41267. * Define an offset for the lens center.
  41268. */
  41269. lensCenterOffset: number;
  41270. /**
  41271. * Define if the current vr camera should compensate the distortion of the lense or not.
  41272. */
  41273. compensateDistortion: boolean;
  41274. /**
  41275. * Defines if multiview should be enabled when rendering (Default: false)
  41276. */
  41277. multiviewEnabled: boolean;
  41278. /**
  41279. * Gets the rendering aspect ratio based on the provided resolutions.
  41280. */
  41281. readonly aspectRatio: number;
  41282. /**
  41283. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41284. */
  41285. readonly aspectRatioFov: number;
  41286. /**
  41287. * @hidden
  41288. */
  41289. readonly leftHMatrix: Matrix;
  41290. /**
  41291. * @hidden
  41292. */
  41293. readonly rightHMatrix: Matrix;
  41294. /**
  41295. * @hidden
  41296. */
  41297. readonly leftPreViewMatrix: Matrix;
  41298. /**
  41299. * @hidden
  41300. */
  41301. readonly rightPreViewMatrix: Matrix;
  41302. /**
  41303. * Get the default VRMetrics based on the most generic setup.
  41304. * @returns the default vr metrics
  41305. */
  41306. static GetDefault(): VRCameraMetrics;
  41307. }
  41308. }
  41309. declare module BABYLON {
  41310. /** @hidden */
  41311. export var vrDistortionCorrectionPixelShader: {
  41312. name: string;
  41313. shader: string;
  41314. };
  41315. }
  41316. declare module BABYLON {
  41317. /**
  41318. * VRDistortionCorrectionPostProcess used for mobile VR
  41319. */
  41320. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41321. private _isRightEye;
  41322. private _distortionFactors;
  41323. private _postProcessScaleFactor;
  41324. private _lensCenterOffset;
  41325. private _scaleIn;
  41326. private _scaleFactor;
  41327. private _lensCenter;
  41328. /**
  41329. * Initializes the VRDistortionCorrectionPostProcess
  41330. * @param name The name of the effect.
  41331. * @param camera The camera to apply the render pass to.
  41332. * @param isRightEye If this is for the right eye distortion
  41333. * @param vrMetrics All the required metrics for the VR camera
  41334. */
  41335. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41336. }
  41337. }
  41338. declare module BABYLON {
  41339. /**
  41340. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41341. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41342. */
  41343. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41344. /**
  41345. * Creates a new VRDeviceOrientationArcRotateCamera
  41346. * @param name defines camera name
  41347. * @param alpha defines the camera rotation along the logitudinal axis
  41348. * @param beta defines the camera rotation along the latitudinal axis
  41349. * @param radius defines the camera distance from its target
  41350. * @param target defines the camera target
  41351. * @param scene defines the scene the camera belongs to
  41352. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41353. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41354. */
  41355. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41356. /**
  41357. * Gets camera class name
  41358. * @returns VRDeviceOrientationArcRotateCamera
  41359. */
  41360. getClassName(): string;
  41361. }
  41362. }
  41363. declare module BABYLON {
  41364. /**
  41365. * Camera used to simulate VR rendering (based on FreeCamera)
  41366. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41367. */
  41368. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41369. /**
  41370. * Creates a new VRDeviceOrientationFreeCamera
  41371. * @param name defines camera name
  41372. * @param position defines the start position of the camera
  41373. * @param scene defines the scene the camera belongs to
  41374. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41375. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41376. */
  41377. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41378. /**
  41379. * Gets camera class name
  41380. * @returns VRDeviceOrientationFreeCamera
  41381. */
  41382. getClassName(): string;
  41383. }
  41384. }
  41385. declare module BABYLON {
  41386. /**
  41387. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41388. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41389. */
  41390. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41391. /**
  41392. * Creates a new VRDeviceOrientationGamepadCamera
  41393. * @param name defines camera name
  41394. * @param position defines the start position of the camera
  41395. * @param scene defines the scene the camera belongs to
  41396. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41397. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41398. */
  41399. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41400. /**
  41401. * Gets camera class name
  41402. * @returns VRDeviceOrientationGamepadCamera
  41403. */
  41404. getClassName(): string;
  41405. }
  41406. }
  41407. declare module BABYLON {
  41408. /** @hidden */
  41409. export var imageProcessingPixelShader: {
  41410. name: string;
  41411. shader: string;
  41412. };
  41413. }
  41414. declare module BABYLON {
  41415. /**
  41416. * ImageProcessingPostProcess
  41417. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41418. */
  41419. export class ImageProcessingPostProcess extends PostProcess {
  41420. /**
  41421. * Default configuration related to image processing available in the PBR Material.
  41422. */
  41423. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41424. /**
  41425. * Gets the image processing configuration used either in this material.
  41426. */
  41427. /**
  41428. * Sets the Default image processing configuration used either in the this material.
  41429. *
  41430. * If sets to null, the scene one is in use.
  41431. */
  41432. imageProcessingConfiguration: ImageProcessingConfiguration;
  41433. /**
  41434. * Keep track of the image processing observer to allow dispose and replace.
  41435. */
  41436. private _imageProcessingObserver;
  41437. /**
  41438. * Attaches a new image processing configuration to the PBR Material.
  41439. * @param configuration
  41440. */
  41441. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41442. /**
  41443. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41444. */
  41445. /**
  41446. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41447. */
  41448. colorCurves: Nullable<ColorCurves>;
  41449. /**
  41450. * Gets wether the color curves effect is enabled.
  41451. */
  41452. /**
  41453. * Sets wether the color curves effect is enabled.
  41454. */
  41455. colorCurvesEnabled: boolean;
  41456. /**
  41457. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41458. */
  41459. /**
  41460. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41461. */
  41462. colorGradingTexture: Nullable<BaseTexture>;
  41463. /**
  41464. * Gets wether the color grading effect is enabled.
  41465. */
  41466. /**
  41467. * Gets wether the color grading effect is enabled.
  41468. */
  41469. colorGradingEnabled: boolean;
  41470. /**
  41471. * Gets exposure used in the effect.
  41472. */
  41473. /**
  41474. * Sets exposure used in the effect.
  41475. */
  41476. exposure: number;
  41477. /**
  41478. * Gets wether tonemapping is enabled or not.
  41479. */
  41480. /**
  41481. * Sets wether tonemapping is enabled or not
  41482. */
  41483. toneMappingEnabled: boolean;
  41484. /**
  41485. * Gets the type of tone mapping effect.
  41486. */
  41487. /**
  41488. * Sets the type of tone mapping effect.
  41489. */
  41490. toneMappingType: number;
  41491. /**
  41492. * Gets contrast used in the effect.
  41493. */
  41494. /**
  41495. * Sets contrast used in the effect.
  41496. */
  41497. contrast: number;
  41498. /**
  41499. * Gets Vignette stretch size.
  41500. */
  41501. /**
  41502. * Sets Vignette stretch size.
  41503. */
  41504. vignetteStretch: number;
  41505. /**
  41506. * Gets Vignette centre X Offset.
  41507. */
  41508. /**
  41509. * Sets Vignette centre X Offset.
  41510. */
  41511. vignetteCentreX: number;
  41512. /**
  41513. * Gets Vignette centre Y Offset.
  41514. */
  41515. /**
  41516. * Sets Vignette centre Y Offset.
  41517. */
  41518. vignetteCentreY: number;
  41519. /**
  41520. * Gets Vignette weight or intensity of the vignette effect.
  41521. */
  41522. /**
  41523. * Sets Vignette weight or intensity of the vignette effect.
  41524. */
  41525. vignetteWeight: number;
  41526. /**
  41527. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41528. * if vignetteEnabled is set to true.
  41529. */
  41530. /**
  41531. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41532. * if vignetteEnabled is set to true.
  41533. */
  41534. vignetteColor: Color4;
  41535. /**
  41536. * Gets Camera field of view used by the Vignette effect.
  41537. */
  41538. /**
  41539. * Sets Camera field of view used by the Vignette effect.
  41540. */
  41541. vignetteCameraFov: number;
  41542. /**
  41543. * Gets the vignette blend mode allowing different kind of effect.
  41544. */
  41545. /**
  41546. * Sets the vignette blend mode allowing different kind of effect.
  41547. */
  41548. vignetteBlendMode: number;
  41549. /**
  41550. * Gets wether the vignette effect is enabled.
  41551. */
  41552. /**
  41553. * Sets wether the vignette effect is enabled.
  41554. */
  41555. vignetteEnabled: boolean;
  41556. private _fromLinearSpace;
  41557. /**
  41558. * Gets wether the input of the processing is in Gamma or Linear Space.
  41559. */
  41560. /**
  41561. * Sets wether the input of the processing is in Gamma or Linear Space.
  41562. */
  41563. fromLinearSpace: boolean;
  41564. /**
  41565. * Defines cache preventing GC.
  41566. */
  41567. private _defines;
  41568. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41569. /**
  41570. * "ImageProcessingPostProcess"
  41571. * @returns "ImageProcessingPostProcess"
  41572. */
  41573. getClassName(): string;
  41574. protected _updateParameters(): void;
  41575. dispose(camera?: Camera): void;
  41576. }
  41577. }
  41578. declare module BABYLON {
  41579. /**
  41580. * Class containing static functions to help procedurally build meshes
  41581. */
  41582. export class GroundBuilder {
  41583. /**
  41584. * Creates a ground mesh
  41585. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41586. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41588. * @param name defines the name of the mesh
  41589. * @param options defines the options used to create the mesh
  41590. * @param scene defines the hosting scene
  41591. * @returns the ground mesh
  41592. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41593. */
  41594. static CreateGround(name: string, options: {
  41595. width?: number;
  41596. height?: number;
  41597. subdivisions?: number;
  41598. subdivisionsX?: number;
  41599. subdivisionsY?: number;
  41600. updatable?: boolean;
  41601. }, scene: any): Mesh;
  41602. /**
  41603. * Creates a tiled ground mesh
  41604. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41605. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41606. * * 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
  41607. * * 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
  41608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41609. * @param name defines the name of the mesh
  41610. * @param options defines the options used to create the mesh
  41611. * @param scene defines the hosting scene
  41612. * @returns the tiled ground mesh
  41613. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41614. */
  41615. static CreateTiledGround(name: string, options: {
  41616. xmin: number;
  41617. zmin: number;
  41618. xmax: number;
  41619. zmax: number;
  41620. subdivisions?: {
  41621. w: number;
  41622. h: number;
  41623. };
  41624. precision?: {
  41625. w: number;
  41626. h: number;
  41627. };
  41628. updatable?: boolean;
  41629. }, scene?: Nullable<Scene>): Mesh;
  41630. /**
  41631. * Creates a ground mesh from a height map
  41632. * * The parameter `url` sets the URL of the height map image resource.
  41633. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41634. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41635. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41636. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41637. * * 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.
  41638. * * 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).
  41639. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41641. * @param name defines the name of the mesh
  41642. * @param url defines the url to the height map
  41643. * @param options defines the options used to create the mesh
  41644. * @param scene defines the hosting scene
  41645. * @returns the ground mesh
  41646. * @see https://doc.babylonjs.com/babylon101/height_map
  41647. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41648. */
  41649. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41650. width?: number;
  41651. height?: number;
  41652. subdivisions?: number;
  41653. minHeight?: number;
  41654. maxHeight?: number;
  41655. colorFilter?: Color3;
  41656. alphaFilter?: number;
  41657. updatable?: boolean;
  41658. onReady?: (mesh: GroundMesh) => void;
  41659. }, scene?: Nullable<Scene>): GroundMesh;
  41660. }
  41661. }
  41662. declare module BABYLON {
  41663. /**
  41664. * Class containing static functions to help procedurally build meshes
  41665. */
  41666. export class TorusBuilder {
  41667. /**
  41668. * Creates a torus mesh
  41669. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41670. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41671. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41672. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41673. * * 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
  41674. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41675. * @param name defines the name of the mesh
  41676. * @param options defines the options used to create the mesh
  41677. * @param scene defines the hosting scene
  41678. * @returns the torus mesh
  41679. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41680. */
  41681. static CreateTorus(name: string, options: {
  41682. diameter?: number;
  41683. thickness?: number;
  41684. tessellation?: number;
  41685. updatable?: boolean;
  41686. sideOrientation?: number;
  41687. frontUVs?: Vector4;
  41688. backUVs?: Vector4;
  41689. }, scene: any): Mesh;
  41690. }
  41691. }
  41692. declare module BABYLON {
  41693. /**
  41694. * Class containing static functions to help procedurally build meshes
  41695. */
  41696. export class CylinderBuilder {
  41697. /**
  41698. * Creates a cylinder or a cone mesh
  41699. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41700. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41701. * * 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.
  41702. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41703. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41704. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41705. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41706. * * 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).
  41707. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41708. * * 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).
  41709. * * 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
  41710. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41711. * * 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
  41712. * * 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.
  41713. * * If `enclose` is false, a ring surface is one element.
  41714. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41715. * * 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
  41716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41717. * * 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
  41718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41719. * @param name defines the name of the mesh
  41720. * @param options defines the options used to create the mesh
  41721. * @param scene defines the hosting scene
  41722. * @returns the cylinder mesh
  41723. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41724. */
  41725. static CreateCylinder(name: string, options: {
  41726. height?: number;
  41727. diameterTop?: number;
  41728. diameterBottom?: number;
  41729. diameter?: number;
  41730. tessellation?: number;
  41731. subdivisions?: number;
  41732. arc?: number;
  41733. faceColors?: Color4[];
  41734. faceUV?: Vector4[];
  41735. updatable?: boolean;
  41736. hasRings?: boolean;
  41737. enclose?: boolean;
  41738. cap?: number;
  41739. sideOrientation?: number;
  41740. frontUVs?: Vector4;
  41741. backUVs?: Vector4;
  41742. }, scene: any): Mesh;
  41743. }
  41744. }
  41745. declare module BABYLON {
  41746. /**
  41747. * States of the webXR experience
  41748. */
  41749. export enum WebXRState {
  41750. /**
  41751. * Transitioning to being in XR mode
  41752. */
  41753. ENTERING_XR = 0,
  41754. /**
  41755. * Transitioning to non XR mode
  41756. */
  41757. EXITING_XR = 1,
  41758. /**
  41759. * In XR mode and presenting
  41760. */
  41761. IN_XR = 2,
  41762. /**
  41763. * Not entered XR mode
  41764. */
  41765. NOT_IN_XR = 3
  41766. }
  41767. /**
  41768. * Abstraction of the XR render target
  41769. */
  41770. export interface WebXRRenderTarget extends IDisposable {
  41771. /**
  41772. * xrpresent context of the canvas which can be used to display/mirror xr content
  41773. */
  41774. canvasContext: WebGLRenderingContext;
  41775. /**
  41776. * xr layer for the canvas
  41777. */
  41778. xrLayer: Nullable<XRWebGLLayer>;
  41779. /**
  41780. * Initializes the xr layer for the session
  41781. * @param xrSession xr session
  41782. * @returns a promise that will resolve once the XR Layer has been created
  41783. */
  41784. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  41785. }
  41786. }
  41787. declare module BABYLON {
  41788. /**
  41789. * COnfiguration object for WebXR output canvas
  41790. */
  41791. export class WebXRManagedOutputCanvasOptions {
  41792. /**
  41793. * Options for this XR Layer output
  41794. */
  41795. canvasOptions: XRWebGLLayerOptions;
  41796. /**
  41797. * CSS styling for a newly created canvas (if not provided)
  41798. */
  41799. newCanvasCssStyle?: string;
  41800. /**
  41801. * Get the default values of the configuration object
  41802. * @returns default values of this configuration object
  41803. */
  41804. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  41805. }
  41806. /**
  41807. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41808. */
  41809. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  41810. private configuration;
  41811. private _engine;
  41812. private _canvas;
  41813. /**
  41814. * xrpresent context of the canvas which can be used to display/mirror xr content
  41815. */
  41816. canvasContext: WebGLRenderingContext;
  41817. /**
  41818. * xr layer for the canvas
  41819. */
  41820. xrLayer: Nullable<XRWebGLLayer>;
  41821. /**
  41822. * Initializes the xr layer for the session
  41823. * @param xrSession xr session
  41824. * @returns a promise that will resolve once the XR Layer has been created
  41825. */
  41826. initializeXRLayerAsync(xrSession: any): any;
  41827. /**
  41828. * Initializes the canvas to be added/removed upon entering/exiting xr
  41829. * @param engine the Babylon engine
  41830. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41831. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  41832. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  41833. */
  41834. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  41835. /**
  41836. * Disposes of the object
  41837. */
  41838. dispose(): void;
  41839. private _setManagedOutputCanvas;
  41840. private _addCanvas;
  41841. private _removeCanvas;
  41842. }
  41843. }
  41844. declare module BABYLON {
  41845. /**
  41846. * Manages an XRSession to work with Babylon's engine
  41847. * @see https://doc.babylonjs.com/how_to/webxr
  41848. */
  41849. export class WebXRSessionManager implements IDisposable {
  41850. /** The scene which the session should be created for */
  41851. scene: Scene;
  41852. /**
  41853. * Fires every time a new xrFrame arrives which can be used to update the camera
  41854. */
  41855. onXRFrameObservable: Observable<XRFrame>;
  41856. /**
  41857. * Fires when the xr session is ended either by the device or manually done
  41858. */
  41859. onXRSessionEnded: Observable<any>;
  41860. /**
  41861. * Fires when the xr session is ended either by the device or manually done
  41862. */
  41863. onXRSessionInit: Observable<XRSession>;
  41864. /**
  41865. * Underlying xr session
  41866. */
  41867. session: XRSession;
  41868. /**
  41869. * Type of reference space used when creating the session
  41870. */
  41871. referenceSpace: XRReferenceSpace;
  41872. /**
  41873. * Current XR frame
  41874. */
  41875. currentFrame: Nullable<XRFrame>;
  41876. private _xrNavigator;
  41877. private baseLayer;
  41878. private _rttProvider;
  41879. private _sessionEnded;
  41880. /**
  41881. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41882. * @param scene The scene which the session should be created for
  41883. */
  41884. constructor(
  41885. /** The scene which the session should be created for */
  41886. scene: Scene);
  41887. /**
  41888. * Initializes the manager
  41889. * After initialization enterXR can be called to start an XR session
  41890. * @returns Promise which resolves after it is initialized
  41891. */
  41892. initializeAsync(): Promise<void>;
  41893. /**
  41894. * Initializes an xr session
  41895. * @param xrSessionMode mode to initialize
  41896. * @param optionalFeatures defines optional values to pass to the session builder
  41897. * @returns a promise which will resolve once the session has been initialized
  41898. */
  41899. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  41900. /**
  41901. * Sets the reference space on the xr session
  41902. * @param referenceSpace space to set
  41903. * @returns a promise that will resolve once the reference space has been set
  41904. */
  41905. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41906. /**
  41907. * Updates the render state of the session
  41908. * @param state state to set
  41909. * @returns a promise that resolves once the render state has been updated
  41910. */
  41911. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41912. /**
  41913. * Starts rendering to the xr layer
  41914. * @returns a promise that will resolve once rendering has started
  41915. */
  41916. startRenderingToXRAsync(): Promise<void>;
  41917. /**
  41918. * Gets the correct render target texture to be rendered this frame for this eye
  41919. * @param eye the eye for which to get the render target
  41920. * @returns the render target for the specified eye
  41921. */
  41922. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  41923. /**
  41924. * Stops the xrSession and restores the renderloop
  41925. * @returns Promise which resolves after it exits XR
  41926. */
  41927. exitXRAsync(): Promise<void>;
  41928. /**
  41929. * Checks if a session would be supported for the creation options specified
  41930. * @param sessionMode session mode to check if supported eg. immersive-vr
  41931. * @returns true if supported
  41932. */
  41933. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  41934. /**
  41935. * Creates a WebXRRenderTarget object for the XR session
  41936. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  41937. * @param options optional options to provide when creating a new render target
  41938. * @returns a WebXR render target to which the session can render
  41939. */
  41940. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  41941. /**
  41942. * @hidden
  41943. * Converts the render layer of xrSession to a render target
  41944. * @param session session to create render target for
  41945. * @param scene scene the new render target should be created for
  41946. * @param baseLayer the webgl layer to create the render target for
  41947. */
  41948. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41949. /**
  41950. * Disposes of the session manager
  41951. */
  41952. dispose(): void;
  41953. /**
  41954. * Gets a promise returning true when fullfiled if the given session mode is supported
  41955. * @param sessionMode defines the session to test
  41956. * @returns a promise
  41957. */
  41958. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  41959. }
  41960. }
  41961. declare module BABYLON {
  41962. /**
  41963. * WebXR Camera which holds the views for the xrSession
  41964. * @see https://doc.babylonjs.com/how_to/webxr
  41965. */
  41966. export class WebXRCamera extends FreeCamera {
  41967. /**
  41968. * Is the camera in debug mode. Used when using an emulator
  41969. */
  41970. debugMode: boolean;
  41971. /**
  41972. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41973. * @param name the name of the camera
  41974. * @param scene the scene to add the camera to
  41975. */
  41976. constructor(name: string, scene: Scene);
  41977. private _updateNumberOfRigCameras;
  41978. /** @hidden */
  41979. _updateForDualEyeDebugging(): void;
  41980. /**
  41981. * Updates the cameras position from the current pose information of the XR session
  41982. * @param xrSessionManager the session containing pose information
  41983. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41984. */
  41985. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41986. }
  41987. }
  41988. declare module BABYLON {
  41989. /**
  41990. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41991. * @see https://doc.babylonjs.com/how_to/webxr
  41992. */
  41993. export class WebXRExperienceHelper implements IDisposable {
  41994. private scene;
  41995. /**
  41996. * 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
  41997. */
  41998. container: AbstractMesh;
  41999. /**
  42000. * Camera used to render xr content
  42001. */
  42002. camera: WebXRCamera;
  42003. /**
  42004. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42005. */
  42006. state: WebXRState;
  42007. private _setState;
  42008. private static _TmpVector;
  42009. /**
  42010. * Fires when the state of the experience helper has changed
  42011. */
  42012. onStateChangedObservable: Observable<WebXRState>;
  42013. /** Session manager used to keep track of xr session */
  42014. sessionManager: WebXRSessionManager;
  42015. private _nonVRCamera;
  42016. private _originalSceneAutoClear;
  42017. private _supported;
  42018. /**
  42019. * Creates the experience helper
  42020. * @param scene the scene to attach the experience helper to
  42021. * @returns a promise for the experience helper
  42022. */
  42023. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42024. /**
  42025. * Creates a WebXRExperienceHelper
  42026. * @param scene The scene the helper should be created in
  42027. */
  42028. private constructor();
  42029. /**
  42030. * Exits XR mode and returns the scene to its original state
  42031. * @returns promise that resolves after xr mode has exited
  42032. */
  42033. exitXRAsync(): Promise<void>;
  42034. /**
  42035. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42036. * @param sessionMode options for the XR session
  42037. * @param referenceSpaceType frame of reference of the XR session
  42038. * @param renderTarget the output canvas that will be used to enter XR mode
  42039. * @returns promise that resolves after xr mode has entered
  42040. */
  42041. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  42042. /**
  42043. * Updates the global position of the camera by moving the camera's container
  42044. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42045. * @param position The desired global position of the camera
  42046. */
  42047. setPositionOfCameraUsingContainer(position: Vector3): void;
  42048. /**
  42049. * Rotates the xr camera by rotating the camera's container around the camera's position
  42050. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42051. * @param rotation the desired quaternion rotation to apply to the camera
  42052. */
  42053. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42054. /**
  42055. * Disposes of the experience helper
  42056. */
  42057. dispose(): void;
  42058. }
  42059. }
  42060. declare module BABYLON {
  42061. /**
  42062. * Represents an XR input
  42063. */
  42064. export class WebXRController {
  42065. private scene;
  42066. /** The underlying input source for the controller */
  42067. inputSource: XRInputSource;
  42068. private parentContainer;
  42069. /**
  42070. * 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
  42071. */
  42072. grip?: AbstractMesh;
  42073. /**
  42074. * Pointer which can be used to select objects or attach a visible laser to
  42075. */
  42076. pointer: AbstractMesh;
  42077. private _gamepadMode;
  42078. /**
  42079. * If available, this is the gamepad object related to this controller.
  42080. * Using this object it is possible to get click events and trackpad changes of the
  42081. * webxr controller that is currently being used.
  42082. */
  42083. gamepadController?: WebVRController;
  42084. /**
  42085. * Event that fires when the controller is removed/disposed
  42086. */
  42087. onDisposeObservable: Observable<{}>;
  42088. private _tmpQuaternion;
  42089. private _tmpVector;
  42090. /**
  42091. * Creates the controller
  42092. * @see https://doc.babylonjs.com/how_to/webxr
  42093. * @param scene the scene which the controller should be associated to
  42094. * @param inputSource the underlying input source for the controller
  42095. * @param parentContainer parent that the controller meshes should be children of
  42096. */
  42097. constructor(scene: Scene,
  42098. /** The underlying input source for the controller */
  42099. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42100. /**
  42101. * Updates the controller pose based on the given XRFrame
  42102. * @param xrFrame xr frame to update the pose with
  42103. * @param referenceSpace reference space to use
  42104. */
  42105. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42106. /**
  42107. * Gets a world space ray coming from the controller
  42108. * @param result the resulting ray
  42109. */
  42110. getWorldPointerRayToRef(result: Ray): void;
  42111. /**
  42112. * Get the scene associated with this controller
  42113. * @returns the scene object
  42114. */
  42115. getScene(): Scene;
  42116. /**
  42117. * Disposes of the object
  42118. */
  42119. dispose(): void;
  42120. }
  42121. }
  42122. declare module BABYLON {
  42123. /**
  42124. * XR input used to track XR inputs such as controllers/rays
  42125. */
  42126. export class WebXRInput implements IDisposable {
  42127. /**
  42128. * Base experience the input listens to
  42129. */
  42130. baseExperience: WebXRExperienceHelper;
  42131. /**
  42132. * XR controllers being tracked
  42133. */
  42134. controllers: Array<WebXRController>;
  42135. private _frameObserver;
  42136. private _stateObserver;
  42137. /**
  42138. * Event when a controller has been connected/added
  42139. */
  42140. onControllerAddedObservable: Observable<WebXRController>;
  42141. /**
  42142. * Event when a controller has been removed/disconnected
  42143. */
  42144. onControllerRemovedObservable: Observable<WebXRController>;
  42145. /**
  42146. * Initializes the WebXRInput
  42147. * @param baseExperience experience helper which the input should be created for
  42148. */
  42149. constructor(
  42150. /**
  42151. * Base experience the input listens to
  42152. */
  42153. baseExperience: WebXRExperienceHelper);
  42154. private _onInputSourcesChange;
  42155. private _addAndRemoveControllers;
  42156. /**
  42157. * Disposes of the object
  42158. */
  42159. dispose(): void;
  42160. }
  42161. }
  42162. declare module BABYLON {
  42163. /**
  42164. * Class used to represent data loading progression
  42165. */
  42166. export class SceneLoaderProgressEvent {
  42167. /** defines if data length to load can be evaluated */
  42168. readonly lengthComputable: boolean;
  42169. /** defines the loaded data length */
  42170. readonly loaded: number;
  42171. /** defines the data length to load */
  42172. readonly total: number;
  42173. /**
  42174. * Create a new progress event
  42175. * @param lengthComputable defines if data length to load can be evaluated
  42176. * @param loaded defines the loaded data length
  42177. * @param total defines the data length to load
  42178. */
  42179. constructor(
  42180. /** defines if data length to load can be evaluated */
  42181. lengthComputable: boolean,
  42182. /** defines the loaded data length */
  42183. loaded: number,
  42184. /** defines the data length to load */
  42185. total: number);
  42186. /**
  42187. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42188. * @param event defines the source event
  42189. * @returns a new SceneLoaderProgressEvent
  42190. */
  42191. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42192. }
  42193. /**
  42194. * Interface used by SceneLoader plugins to define supported file extensions
  42195. */
  42196. export interface ISceneLoaderPluginExtensions {
  42197. /**
  42198. * Defines the list of supported extensions
  42199. */
  42200. [extension: string]: {
  42201. isBinary: boolean;
  42202. };
  42203. }
  42204. /**
  42205. * Interface used by SceneLoader plugin factory
  42206. */
  42207. export interface ISceneLoaderPluginFactory {
  42208. /**
  42209. * Defines the name of the factory
  42210. */
  42211. name: string;
  42212. /**
  42213. * Function called to create a new plugin
  42214. * @return the new plugin
  42215. */
  42216. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42217. /**
  42218. * The callback that returns true if the data can be directly loaded.
  42219. * @param data string containing the file data
  42220. * @returns if the data can be loaded directly
  42221. */
  42222. canDirectLoad?(data: string): boolean;
  42223. }
  42224. /**
  42225. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  42226. */
  42227. export interface ISceneLoaderPluginBase {
  42228. /**
  42229. * The friendly name of this plugin.
  42230. */
  42231. name: string;
  42232. /**
  42233. * The file extensions supported by this plugin.
  42234. */
  42235. extensions: string | ISceneLoaderPluginExtensions;
  42236. /**
  42237. * The callback called when loading from a url.
  42238. * @param scene scene loading this url
  42239. * @param url url to load
  42240. * @param onSuccess callback called when the file successfully loads
  42241. * @param onProgress callback called while file is loading (if the server supports this mode)
  42242. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42243. * @param onError callback called when the file fails to load
  42244. * @returns a file request object
  42245. */
  42246. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42247. /**
  42248. * The callback called when loading from a file object.
  42249. * @param scene scene loading this file
  42250. * @param file defines the file to load
  42251. * @param onSuccess defines the callback to call when data is loaded
  42252. * @param onProgress defines the callback to call during loading process
  42253. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42254. * @param onError defines the callback to call when an error occurs
  42255. * @returns a file request object
  42256. */
  42257. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42258. /**
  42259. * The callback that returns true if the data can be directly loaded.
  42260. * @param data string containing the file data
  42261. * @returns if the data can be loaded directly
  42262. */
  42263. canDirectLoad?(data: string): boolean;
  42264. /**
  42265. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  42266. * @param scene scene loading this data
  42267. * @param data string containing the data
  42268. * @returns data to pass to the plugin
  42269. */
  42270. directLoad?(scene: Scene, data: string): any;
  42271. /**
  42272. * The callback that allows custom handling of the root url based on the response url.
  42273. * @param rootUrl the original root url
  42274. * @param responseURL the response url if available
  42275. * @returns the new root url
  42276. */
  42277. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  42278. }
  42279. /**
  42280. * Interface used to define a SceneLoader plugin
  42281. */
  42282. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  42283. /**
  42284. * Import meshes into a scene.
  42285. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42286. * @param scene The scene to import into
  42287. * @param data The data to import
  42288. * @param rootUrl The root url for scene and resources
  42289. * @param meshes The meshes array to import into
  42290. * @param particleSystems The particle systems array to import into
  42291. * @param skeletons The skeletons array to import into
  42292. * @param onError The callback when import fails
  42293. * @returns True if successful or false otherwise
  42294. */
  42295. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42296. /**
  42297. * Load into a scene.
  42298. * @param scene The scene to load into
  42299. * @param data The data to import
  42300. * @param rootUrl The root url for scene and resources
  42301. * @param onError The callback when import fails
  42302. * @returns True if successful or false otherwise
  42303. */
  42304. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42305. /**
  42306. * Load into an asset container.
  42307. * @param scene The scene to load into
  42308. * @param data The data to import
  42309. * @param rootUrl The root url for scene and resources
  42310. * @param onError The callback when import fails
  42311. * @returns The loaded asset container
  42312. */
  42313. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42314. }
  42315. /**
  42316. * Interface used to define an async SceneLoader plugin
  42317. */
  42318. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  42319. /**
  42320. * Import meshes into a scene.
  42321. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42322. * @param scene The scene to import into
  42323. * @param data The data to import
  42324. * @param rootUrl The root url for scene and resources
  42325. * @param onProgress The callback when the load progresses
  42326. * @param fileName Defines the name of the file to load
  42327. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42328. */
  42329. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42330. meshes: AbstractMesh[];
  42331. particleSystems: IParticleSystem[];
  42332. skeletons: Skeleton[];
  42333. animationGroups: AnimationGroup[];
  42334. }>;
  42335. /**
  42336. * Load into a scene.
  42337. * @param scene The scene to load into
  42338. * @param data The data to import
  42339. * @param rootUrl The root url for scene and resources
  42340. * @param onProgress The callback when the load progresses
  42341. * @param fileName Defines the name of the file to load
  42342. * @returns Nothing
  42343. */
  42344. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42345. /**
  42346. * Load into an asset container.
  42347. * @param scene The scene to load into
  42348. * @param data The data to import
  42349. * @param rootUrl The root url for scene and resources
  42350. * @param onProgress The callback when the load progresses
  42351. * @param fileName Defines the name of the file to load
  42352. * @returns The loaded asset container
  42353. */
  42354. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42355. }
  42356. /**
  42357. * Mode that determines how to handle old animation groups before loading new ones.
  42358. */
  42359. export enum SceneLoaderAnimationGroupLoadingMode {
  42360. /**
  42361. * Reset all old animations to initial state then dispose them.
  42362. */
  42363. Clean = 0,
  42364. /**
  42365. * Stop all old animations.
  42366. */
  42367. Stop = 1,
  42368. /**
  42369. * Restart old animations from first frame.
  42370. */
  42371. Sync = 2,
  42372. /**
  42373. * Old animations remains untouched.
  42374. */
  42375. NoSync = 3
  42376. }
  42377. /**
  42378. * Class used to load scene from various file formats using registered plugins
  42379. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42380. */
  42381. export class SceneLoader {
  42382. /**
  42383. * No logging while loading
  42384. */
  42385. static readonly NO_LOGGING: number;
  42386. /**
  42387. * Minimal logging while loading
  42388. */
  42389. static readonly MINIMAL_LOGGING: number;
  42390. /**
  42391. * Summary logging while loading
  42392. */
  42393. static readonly SUMMARY_LOGGING: number;
  42394. /**
  42395. * Detailled logging while loading
  42396. */
  42397. static readonly DETAILED_LOGGING: number;
  42398. /**
  42399. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42400. */
  42401. static ForceFullSceneLoadingForIncremental: boolean;
  42402. /**
  42403. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42404. */
  42405. static ShowLoadingScreen: boolean;
  42406. /**
  42407. * Defines the current logging level (while loading the scene)
  42408. * @ignorenaming
  42409. */
  42410. static loggingLevel: number;
  42411. /**
  42412. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42413. */
  42414. static CleanBoneMatrixWeights: boolean;
  42415. /**
  42416. * Event raised when a plugin is used to load a scene
  42417. */
  42418. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42419. private static _registeredPlugins;
  42420. private static _getDefaultPlugin;
  42421. private static _getPluginForExtension;
  42422. private static _getPluginForDirectLoad;
  42423. private static _getPluginForFilename;
  42424. private static _getDirectLoad;
  42425. private static _loadData;
  42426. private static _getFileInfo;
  42427. /**
  42428. * Gets a plugin that can load the given extension
  42429. * @param extension defines the extension to load
  42430. * @returns a plugin or null if none works
  42431. */
  42432. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42433. /**
  42434. * Gets a boolean indicating that the given extension can be loaded
  42435. * @param extension defines the extension to load
  42436. * @returns true if the extension is supported
  42437. */
  42438. static IsPluginForExtensionAvailable(extension: string): boolean;
  42439. /**
  42440. * Adds a new plugin to the list of registered plugins
  42441. * @param plugin defines the plugin to add
  42442. */
  42443. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42444. /**
  42445. * Import meshes into a scene
  42446. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42447. * @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)
  42448. * @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)
  42449. * @param scene the instance of BABYLON.Scene to append to
  42450. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42451. * @param onProgress a callback with a progress event for each file being loaded
  42452. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42453. * @param pluginExtension the extension used to determine the plugin
  42454. * @returns The loaded plugin
  42455. */
  42456. 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>;
  42457. /**
  42458. * Import meshes into a scene
  42459. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42460. * @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)
  42461. * @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)
  42462. * @param scene the instance of BABYLON.Scene to append to
  42463. * @param onProgress a callback with a progress event for each file being loaded
  42464. * @param pluginExtension the extension used to determine the plugin
  42465. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42466. */
  42467. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42468. meshes: AbstractMesh[];
  42469. particleSystems: IParticleSystem[];
  42470. skeletons: Skeleton[];
  42471. animationGroups: AnimationGroup[];
  42472. }>;
  42473. /**
  42474. * Load a scene
  42475. * @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)
  42476. * @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)
  42477. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42478. * @param onSuccess a callback with the scene when import succeeds
  42479. * @param onProgress a callback with a progress event for each file being loaded
  42480. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42481. * @param pluginExtension the extension used to determine the plugin
  42482. * @returns The loaded plugin
  42483. */
  42484. 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>;
  42485. /**
  42486. * Load a scene
  42487. * @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)
  42488. * @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)
  42489. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42490. * @param onProgress a callback with a progress event for each file being loaded
  42491. * @param pluginExtension the extension used to determine the plugin
  42492. * @returns The loaded scene
  42493. */
  42494. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42495. /**
  42496. * Append a scene
  42497. * @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)
  42498. * @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)
  42499. * @param scene is the instance of BABYLON.Scene to append to
  42500. * @param onSuccess a callback with the scene when import succeeds
  42501. * @param onProgress a callback with a progress event for each file being loaded
  42502. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42503. * @param pluginExtension the extension used to determine the plugin
  42504. * @returns The loaded plugin
  42505. */
  42506. 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>;
  42507. /**
  42508. * Append a scene
  42509. * @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)
  42510. * @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)
  42511. * @param scene is the instance of BABYLON.Scene to append to
  42512. * @param onProgress a callback with a progress event for each file being loaded
  42513. * @param pluginExtension the extension used to determine the plugin
  42514. * @returns The given scene
  42515. */
  42516. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42517. /**
  42518. * Load a scene into an asset container
  42519. * @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)
  42520. * @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)
  42521. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42522. * @param onSuccess a callback with the scene when import succeeds
  42523. * @param onProgress a callback with a progress event for each file being loaded
  42524. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42525. * @param pluginExtension the extension used to determine the plugin
  42526. * @returns The loaded plugin
  42527. */
  42528. 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>;
  42529. /**
  42530. * Load a scene into an asset container
  42531. * @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)
  42532. * @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)
  42533. * @param scene is the instance of Scene to append to
  42534. * @param onProgress a callback with a progress event for each file being loaded
  42535. * @param pluginExtension the extension used to determine the plugin
  42536. * @returns The loaded asset container
  42537. */
  42538. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42539. /**
  42540. * Import animations from a file into a scene
  42541. * @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)
  42542. * @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)
  42543. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42544. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  42545. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  42546. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  42547. * @param onSuccess a callback with the scene when import succeeds
  42548. * @param onProgress a callback with a progress event for each file being loaded
  42549. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42550. */
  42551. 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;
  42552. /**
  42553. * Import animations from a file into a scene
  42554. * @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)
  42555. * @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)
  42556. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42557. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  42558. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  42559. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  42560. * @param onSuccess a callback with the scene when import succeeds
  42561. * @param onProgress a callback with a progress event for each file being loaded
  42562. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42563. * @returns the updated scene with imported animations
  42564. */
  42565. 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>;
  42566. }
  42567. }
  42568. declare module BABYLON {
  42569. /**
  42570. * Generic Controller
  42571. */
  42572. export class GenericController extends WebVRController {
  42573. /**
  42574. * Base Url for the controller model.
  42575. */
  42576. static readonly MODEL_BASE_URL: string;
  42577. /**
  42578. * File name for the controller model.
  42579. */
  42580. static readonly MODEL_FILENAME: string;
  42581. /**
  42582. * Creates a new GenericController from a gamepad
  42583. * @param vrGamepad the gamepad that the controller should be created from
  42584. */
  42585. constructor(vrGamepad: any);
  42586. /**
  42587. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42588. * @param scene scene in which to add meshes
  42589. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42590. */
  42591. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42592. /**
  42593. * Called once for each button that changed state since the last frame
  42594. * @param buttonIdx Which button index changed
  42595. * @param state New state of the button
  42596. * @param changes Which properties on the state changed since last frame
  42597. */
  42598. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42599. }
  42600. }
  42601. declare module BABYLON {
  42602. /**
  42603. * Defines the WindowsMotionController object that the state of the windows motion controller
  42604. */
  42605. export class WindowsMotionController extends WebVRController {
  42606. /**
  42607. * The base url used to load the left and right controller models
  42608. */
  42609. static MODEL_BASE_URL: string;
  42610. /**
  42611. * The name of the left controller model file
  42612. */
  42613. static MODEL_LEFT_FILENAME: string;
  42614. /**
  42615. * The name of the right controller model file
  42616. */
  42617. static MODEL_RIGHT_FILENAME: string;
  42618. /**
  42619. * The controller name prefix for this controller type
  42620. */
  42621. static readonly GAMEPAD_ID_PREFIX: string;
  42622. /**
  42623. * The controller id pattern for this controller type
  42624. */
  42625. private static readonly GAMEPAD_ID_PATTERN;
  42626. private _loadedMeshInfo;
  42627. protected readonly _mapping: {
  42628. buttons: string[];
  42629. buttonMeshNames: {
  42630. 'trigger': string;
  42631. 'menu': string;
  42632. 'grip': string;
  42633. 'thumbstick': string;
  42634. 'trackpad': string;
  42635. };
  42636. buttonObservableNames: {
  42637. 'trigger': string;
  42638. 'menu': string;
  42639. 'grip': string;
  42640. 'thumbstick': string;
  42641. 'trackpad': string;
  42642. };
  42643. axisMeshNames: string[];
  42644. pointingPoseMeshName: string;
  42645. };
  42646. /**
  42647. * Fired when the trackpad on this controller is clicked
  42648. */
  42649. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42650. /**
  42651. * Fired when the trackpad on this controller is modified
  42652. */
  42653. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42654. /**
  42655. * The current x and y values of this controller's trackpad
  42656. */
  42657. trackpad: StickValues;
  42658. /**
  42659. * Creates a new WindowsMotionController from a gamepad
  42660. * @param vrGamepad the gamepad that the controller should be created from
  42661. */
  42662. constructor(vrGamepad: any);
  42663. /**
  42664. * Fired when the trigger on this controller is modified
  42665. */
  42666. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42667. /**
  42668. * Fired when the menu button on this controller is modified
  42669. */
  42670. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42671. /**
  42672. * Fired when the grip button on this controller is modified
  42673. */
  42674. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42675. /**
  42676. * Fired when the thumbstick button on this controller is modified
  42677. */
  42678. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42679. /**
  42680. * Fired when the touchpad button on this controller is modified
  42681. */
  42682. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42683. /**
  42684. * Fired when the touchpad values on this controller are modified
  42685. */
  42686. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42687. protected _updateTrackpad(): void;
  42688. /**
  42689. * Called once per frame by the engine.
  42690. */
  42691. update(): void;
  42692. /**
  42693. * Called once for each button that changed state since the last frame
  42694. * @param buttonIdx Which button index changed
  42695. * @param state New state of the button
  42696. * @param changes Which properties on the state changed since last frame
  42697. */
  42698. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42699. /**
  42700. * Moves the buttons on the controller mesh based on their current state
  42701. * @param buttonName the name of the button to move
  42702. * @param buttonValue the value of the button which determines the buttons new position
  42703. */
  42704. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42705. /**
  42706. * Moves the axis on the controller mesh based on its current state
  42707. * @param axis the index of the axis
  42708. * @param axisValue the value of the axis which determines the meshes new position
  42709. * @hidden
  42710. */
  42711. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42712. /**
  42713. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42714. * @param scene scene in which to add meshes
  42715. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42716. */
  42717. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42718. /**
  42719. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42720. * can be transformed by button presses and axes values, based on this._mapping.
  42721. *
  42722. * @param scene scene in which the meshes exist
  42723. * @param meshes list of meshes that make up the controller model to process
  42724. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42725. */
  42726. private processModel;
  42727. private createMeshInfo;
  42728. /**
  42729. * Gets the ray of the controller in the direction the controller is pointing
  42730. * @param length the length the resulting ray should be
  42731. * @returns a ray in the direction the controller is pointing
  42732. */
  42733. getForwardRay(length?: number): Ray;
  42734. /**
  42735. * Disposes of the controller
  42736. */
  42737. dispose(): void;
  42738. }
  42739. /**
  42740. * This class represents a new windows motion controller in XR.
  42741. */
  42742. export class XRWindowsMotionController extends WindowsMotionController {
  42743. /**
  42744. * Changing the original WIndowsMotionController mapping to fir the new mapping
  42745. */
  42746. protected readonly _mapping: {
  42747. buttons: string[];
  42748. buttonMeshNames: {
  42749. 'trigger': string;
  42750. 'menu': string;
  42751. 'grip': string;
  42752. 'thumbstick': string;
  42753. 'trackpad': string;
  42754. };
  42755. buttonObservableNames: {
  42756. 'trigger': string;
  42757. 'menu': string;
  42758. 'grip': string;
  42759. 'thumbstick': string;
  42760. 'trackpad': string;
  42761. };
  42762. axisMeshNames: string[];
  42763. pointingPoseMeshName: string;
  42764. };
  42765. /**
  42766. * Construct a new XR-Based windows motion controller
  42767. *
  42768. * @param gamepadInfo the gamepad object from the browser
  42769. */
  42770. constructor(gamepadInfo: any);
  42771. /**
  42772. * holds the thumbstick values (X,Y)
  42773. */
  42774. thumbstickValues: StickValues;
  42775. /**
  42776. * Fired when the thumbstick on this controller is clicked
  42777. */
  42778. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  42779. /**
  42780. * Fired when the thumbstick on this controller is modified
  42781. */
  42782. onThumbstickValuesChangedObservable: Observable<StickValues>;
  42783. /**
  42784. * Fired when the touchpad button on this controller is modified
  42785. */
  42786. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42787. /**
  42788. * Fired when the touchpad values on this controller are modified
  42789. */
  42790. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42791. /**
  42792. * Fired when the thumbstick button on this controller is modified
  42793. * here to prevent breaking changes
  42794. */
  42795. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42796. /**
  42797. * updating the thumbstick(!) and not the trackpad.
  42798. * This is named this way due to the difference between WebVR and XR and to avoid
  42799. * changing the parent class.
  42800. */
  42801. protected _updateTrackpad(): void;
  42802. /**
  42803. * Disposes the class with joy
  42804. */
  42805. dispose(): void;
  42806. }
  42807. }
  42808. declare module BABYLON {
  42809. /**
  42810. * Oculus Touch Controller
  42811. */
  42812. export class OculusTouchController extends WebVRController {
  42813. /**
  42814. * Base Url for the controller model.
  42815. */
  42816. static MODEL_BASE_URL: string;
  42817. /**
  42818. * File name for the left controller model.
  42819. */
  42820. static MODEL_LEFT_FILENAME: string;
  42821. /**
  42822. * File name for the right controller model.
  42823. */
  42824. static MODEL_RIGHT_FILENAME: string;
  42825. /**
  42826. * Base Url for the Quest controller model.
  42827. */
  42828. static QUEST_MODEL_BASE_URL: string;
  42829. /**
  42830. * @hidden
  42831. * If the controllers are running on a device that needs the updated Quest controller models
  42832. */
  42833. static _IsQuest: boolean;
  42834. /**
  42835. * Fired when the secondary trigger on this controller is modified
  42836. */
  42837. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42838. /**
  42839. * Fired when the thumb rest on this controller is modified
  42840. */
  42841. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42842. /**
  42843. * Creates a new OculusTouchController from a gamepad
  42844. * @param vrGamepad the gamepad that the controller should be created from
  42845. */
  42846. constructor(vrGamepad: any);
  42847. /**
  42848. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42849. * @param scene scene in which to add meshes
  42850. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42851. */
  42852. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42853. /**
  42854. * Fired when the A button on this controller is modified
  42855. */
  42856. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42857. /**
  42858. * Fired when the B button on this controller is modified
  42859. */
  42860. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42861. /**
  42862. * Fired when the X button on this controller is modified
  42863. */
  42864. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42865. /**
  42866. * Fired when the Y button on this controller is modified
  42867. */
  42868. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42869. /**
  42870. * Called once for each button that changed state since the last frame
  42871. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42872. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42873. * 2) secondary trigger (same)
  42874. * 3) A (right) X (left), touch, pressed = value
  42875. * 4) B / Y
  42876. * 5) thumb rest
  42877. * @param buttonIdx Which button index changed
  42878. * @param state New state of the button
  42879. * @param changes Which properties on the state changed since last frame
  42880. */
  42881. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42882. }
  42883. }
  42884. declare module BABYLON {
  42885. /**
  42886. * Vive Controller
  42887. */
  42888. export class ViveController extends WebVRController {
  42889. /**
  42890. * Base Url for the controller model.
  42891. */
  42892. static MODEL_BASE_URL: string;
  42893. /**
  42894. * File name for the controller model.
  42895. */
  42896. static MODEL_FILENAME: string;
  42897. /**
  42898. * Creates a new ViveController from a gamepad
  42899. * @param vrGamepad the gamepad that the controller should be created from
  42900. */
  42901. constructor(vrGamepad: any);
  42902. /**
  42903. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42904. * @param scene scene in which to add meshes
  42905. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42906. */
  42907. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42908. /**
  42909. * Fired when the left button on this controller is modified
  42910. */
  42911. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42912. /**
  42913. * Fired when the right button on this controller is modified
  42914. */
  42915. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42916. /**
  42917. * Fired when the menu button on this controller is modified
  42918. */
  42919. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42920. /**
  42921. * Called once for each button that changed state since the last frame
  42922. * Vive mapping:
  42923. * 0: touchpad
  42924. * 1: trigger
  42925. * 2: left AND right buttons
  42926. * 3: menu button
  42927. * @param buttonIdx Which button index changed
  42928. * @param state New state of the button
  42929. * @param changes Which properties on the state changed since last frame
  42930. */
  42931. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42932. }
  42933. }
  42934. declare module BABYLON {
  42935. /**
  42936. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42937. */
  42938. export class WebXRControllerModelLoader {
  42939. /**
  42940. * an observable that triggers when a new model (the mesh itself) was initialized.
  42941. * To know when the mesh was loaded use the controller's own modelLoaded() method
  42942. */
  42943. onControllerModelLoaded: Observable<WebXRController>;
  42944. /**
  42945. * Creates the WebXRControllerModelLoader
  42946. * @param input xr input that creates the controllers
  42947. */
  42948. constructor(input: WebXRInput);
  42949. }
  42950. }
  42951. declare module BABYLON {
  42952. /**
  42953. * Handles pointer input automatically for the pointer of XR controllers
  42954. */
  42955. export class WebXRControllerPointerSelection {
  42956. private static _idCounter;
  42957. private _tmpRay;
  42958. /**
  42959. * Creates a WebXRControllerPointerSelection
  42960. * @param input input manager to setup pointer selection
  42961. */
  42962. constructor(input: WebXRInput);
  42963. private _convertNormalToDirectionOfRay;
  42964. private _updatePointerDistance;
  42965. }
  42966. }
  42967. declare module BABYLON {
  42968. /**
  42969. * Enables teleportation
  42970. */
  42971. export class WebXRControllerTeleportation {
  42972. private _teleportationFillColor;
  42973. private _teleportationBorderColor;
  42974. private _tmpRay;
  42975. private _tmpVector;
  42976. /**
  42977. * Creates a WebXRControllerTeleportation
  42978. * @param input input manager to add teleportation to
  42979. * @param floorMeshes floormeshes which can be teleported to
  42980. */
  42981. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  42982. }
  42983. }
  42984. declare module BABYLON {
  42985. /**
  42986. * Button which can be used to enter a different mode of XR
  42987. */
  42988. export class WebXREnterExitUIButton {
  42989. /** button element */
  42990. element: HTMLElement;
  42991. /** XR initialization options for the button */
  42992. sessionMode: XRSessionMode;
  42993. /** Reference space type */
  42994. referenceSpaceType: XRReferenceSpaceType;
  42995. /**
  42996. * Creates a WebXREnterExitUIButton
  42997. * @param element button element
  42998. * @param sessionMode XR initialization session mode
  42999. * @param referenceSpaceType the type of reference space to be used
  43000. */
  43001. constructor(
  43002. /** button element */
  43003. element: HTMLElement,
  43004. /** XR initialization options for the button */
  43005. sessionMode: XRSessionMode,
  43006. /** Reference space type */
  43007. referenceSpaceType: XRReferenceSpaceType);
  43008. /**
  43009. * Overwritable function which can be used to update the button's visuals when the state changes
  43010. * @param activeButton the current active button in the UI
  43011. */
  43012. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43013. }
  43014. /**
  43015. * Options to create the webXR UI
  43016. */
  43017. export class WebXREnterExitUIOptions {
  43018. /**
  43019. * Context to enter xr with
  43020. */
  43021. renderTarget?: Nullable<WebXRRenderTarget>;
  43022. /**
  43023. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43024. */
  43025. customButtons?: Array<WebXREnterExitUIButton>;
  43026. /**
  43027. * A session mode to use when creating the default button.
  43028. * Default is immersive-vr
  43029. */
  43030. sessionMode?: XRSessionMode;
  43031. /**
  43032. * A reference space type to use when creating the default button.
  43033. * Default is local-floor
  43034. */
  43035. referenceSpaceType?: XRReferenceSpaceType;
  43036. }
  43037. /**
  43038. * UI to allow the user to enter/exit XR mode
  43039. */
  43040. export class WebXREnterExitUI implements IDisposable {
  43041. private scene;
  43042. /** version of the options passed to this UI */
  43043. options: WebXREnterExitUIOptions;
  43044. private _overlay;
  43045. private _buttons;
  43046. private _activeButton;
  43047. /**
  43048. * Fired every time the active button is changed.
  43049. *
  43050. * When xr is entered via a button that launches xr that button will be the callback parameter
  43051. *
  43052. * When exiting xr the callback parameter will be null)
  43053. */
  43054. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43055. /**
  43056. * Creates UI to allow the user to enter/exit XR mode
  43057. * @param scene the scene to add the ui to
  43058. * @param helper the xr experience helper to enter/exit xr with
  43059. * @param options options to configure the UI
  43060. * @returns the created ui
  43061. */
  43062. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43063. /**
  43064. *
  43065. * @param scene babylon scene object to use
  43066. * @param options (read-only) version of the options passed to this UI
  43067. */
  43068. private constructor();
  43069. private _updateButtons;
  43070. /**
  43071. * Disposes of the object
  43072. */
  43073. dispose(): void;
  43074. }
  43075. }
  43076. declare module BABYLON {
  43077. /**
  43078. * Options for the default xr helper
  43079. */
  43080. export class WebXRDefaultExperienceOptions {
  43081. /**
  43082. * Floor meshes that should be used for teleporting
  43083. */
  43084. floorMeshes: Array<AbstractMesh>;
  43085. /**
  43086. * Enable or disable default UI to enter XR
  43087. */
  43088. disableDefaultUI?: boolean;
  43089. /**
  43090. * optional configuration for the output canvas
  43091. */
  43092. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  43093. /**
  43094. * optional UI options. This can be used among other to change session mode and reference space type
  43095. */
  43096. uiOptions?: WebXREnterExitUIOptions;
  43097. }
  43098. /**
  43099. * Default experience which provides a similar setup to the previous webVRExperience
  43100. */
  43101. export class WebXRDefaultExperience {
  43102. /**
  43103. * Base experience
  43104. */
  43105. baseExperience: WebXRExperienceHelper;
  43106. /**
  43107. * Input experience extension
  43108. */
  43109. input: WebXRInput;
  43110. /**
  43111. * Loads the controller models
  43112. */
  43113. controllerModelLoader: WebXRControllerModelLoader;
  43114. /**
  43115. * Enables laser pointer and selection
  43116. */
  43117. pointerSelection: WebXRControllerPointerSelection;
  43118. /**
  43119. * Enables teleportation
  43120. */
  43121. teleportation: WebXRControllerTeleportation;
  43122. /**
  43123. * Enables ui for entering/exiting xr
  43124. */
  43125. enterExitUI: WebXREnterExitUI;
  43126. /**
  43127. * Default target xr should render to
  43128. */
  43129. renderTarget: WebXRRenderTarget;
  43130. /**
  43131. * Creates the default xr experience
  43132. * @param scene scene
  43133. * @param options options for basic configuration
  43134. * @returns resulting WebXRDefaultExperience
  43135. */
  43136. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  43137. private constructor();
  43138. /**
  43139. * DIsposes of the experience helper
  43140. */
  43141. dispose(): void;
  43142. }
  43143. }
  43144. declare module BABYLON {
  43145. /**
  43146. * Options to modify the vr teleportation behavior.
  43147. */
  43148. export interface VRTeleportationOptions {
  43149. /**
  43150. * The name of the mesh which should be used as the teleportation floor. (default: null)
  43151. */
  43152. floorMeshName?: string;
  43153. /**
  43154. * A list of meshes to be used as the teleportation floor. (default: empty)
  43155. */
  43156. floorMeshes?: Mesh[];
  43157. /**
  43158. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  43159. */
  43160. teleportationMode?: number;
  43161. /**
  43162. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  43163. */
  43164. teleportationTime?: number;
  43165. /**
  43166. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  43167. */
  43168. teleportationSpeed?: number;
  43169. /**
  43170. * The easing function used in the animation or null for Linear. (default CircleEase)
  43171. */
  43172. easingFunction?: EasingFunction;
  43173. }
  43174. /**
  43175. * Options to modify the vr experience helper's behavior.
  43176. */
  43177. export interface VRExperienceHelperOptions extends WebVROptions {
  43178. /**
  43179. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  43180. */
  43181. createDeviceOrientationCamera?: boolean;
  43182. /**
  43183. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  43184. */
  43185. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  43186. /**
  43187. * Uses the main button on the controller to toggle the laser casted. (default: true)
  43188. */
  43189. laserToggle?: boolean;
  43190. /**
  43191. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  43192. */
  43193. floorMeshes?: Mesh[];
  43194. /**
  43195. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  43196. */
  43197. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  43198. /**
  43199. * Defines if WebXR should be used instead of WebVR (if available)
  43200. */
  43201. useXR?: boolean;
  43202. }
  43203. /**
  43204. * Event containing information after VR has been entered
  43205. */
  43206. export class OnAfterEnteringVRObservableEvent {
  43207. /**
  43208. * If entering vr was successful
  43209. */
  43210. success: boolean;
  43211. }
  43212. /**
  43213. * Helps to quickly add VR support to an existing scene.
  43214. * See http://doc.babylonjs.com/how_to/webvr_helper
  43215. */
  43216. export class VRExperienceHelper {
  43217. /** Options to modify the vr experience helper's behavior. */
  43218. webVROptions: VRExperienceHelperOptions;
  43219. private _scene;
  43220. private _position;
  43221. private _btnVR;
  43222. private _btnVRDisplayed;
  43223. private _webVRsupported;
  43224. private _webVRready;
  43225. private _webVRrequesting;
  43226. private _webVRpresenting;
  43227. private _hasEnteredVR;
  43228. private _fullscreenVRpresenting;
  43229. private _inputElement;
  43230. private _webVRCamera;
  43231. private _vrDeviceOrientationCamera;
  43232. private _deviceOrientationCamera;
  43233. private _existingCamera;
  43234. private _onKeyDown;
  43235. private _onVrDisplayPresentChange;
  43236. private _onVRDisplayChanged;
  43237. private _onVRRequestPresentStart;
  43238. private _onVRRequestPresentComplete;
  43239. /**
  43240. * 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)
  43241. */
  43242. enableGazeEvenWhenNoPointerLock: boolean;
  43243. /**
  43244. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  43245. */
  43246. exitVROnDoubleTap: boolean;
  43247. /**
  43248. * Observable raised right before entering VR.
  43249. */
  43250. onEnteringVRObservable: Observable<VRExperienceHelper>;
  43251. /**
  43252. * Observable raised when entering VR has completed.
  43253. */
  43254. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  43255. /**
  43256. * Observable raised when exiting VR.
  43257. */
  43258. onExitingVRObservable: Observable<VRExperienceHelper>;
  43259. /**
  43260. * Observable raised when controller mesh is loaded.
  43261. */
  43262. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43263. /** Return this.onEnteringVRObservable
  43264. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  43265. */
  43266. readonly onEnteringVR: Observable<VRExperienceHelper>;
  43267. /** Return this.onExitingVRObservable
  43268. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  43269. */
  43270. readonly onExitingVR: Observable<VRExperienceHelper>;
  43271. /** Return this.onControllerMeshLoadedObservable
  43272. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  43273. */
  43274. readonly onControllerMeshLoaded: Observable<WebVRController>;
  43275. private _rayLength;
  43276. private _useCustomVRButton;
  43277. private _teleportationRequested;
  43278. private _teleportActive;
  43279. private _floorMeshName;
  43280. private _floorMeshesCollection;
  43281. private _teleportationMode;
  43282. private _teleportationTime;
  43283. private _teleportationSpeed;
  43284. private _teleportationEasing;
  43285. private _rotationAllowed;
  43286. private _teleportBackwardsVector;
  43287. private _teleportationTarget;
  43288. private _isDefaultTeleportationTarget;
  43289. private _postProcessMove;
  43290. private _teleportationFillColor;
  43291. private _teleportationBorderColor;
  43292. private _rotationAngle;
  43293. private _haloCenter;
  43294. private _cameraGazer;
  43295. private _padSensibilityUp;
  43296. private _padSensibilityDown;
  43297. private _leftController;
  43298. private _rightController;
  43299. /**
  43300. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  43301. */
  43302. onNewMeshSelected: Observable<AbstractMesh>;
  43303. /**
  43304. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  43305. * This observable will provide the mesh and the controller used to select the mesh
  43306. */
  43307. onMeshSelectedWithController: Observable<{
  43308. mesh: AbstractMesh;
  43309. controller: WebVRController;
  43310. }>;
  43311. /**
  43312. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  43313. */
  43314. onNewMeshPicked: Observable<PickingInfo>;
  43315. private _circleEase;
  43316. /**
  43317. * Observable raised before camera teleportation
  43318. */
  43319. onBeforeCameraTeleport: Observable<Vector3>;
  43320. /**
  43321. * Observable raised after camera teleportation
  43322. */
  43323. onAfterCameraTeleport: Observable<Vector3>;
  43324. /**
  43325. * Observable raised when current selected mesh gets unselected
  43326. */
  43327. onSelectedMeshUnselected: Observable<AbstractMesh>;
  43328. private _raySelectionPredicate;
  43329. /**
  43330. * To be optionaly changed by user to define custom ray selection
  43331. */
  43332. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  43333. /**
  43334. * To be optionaly changed by user to define custom selection logic (after ray selection)
  43335. */
  43336. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43337. /**
  43338. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  43339. */
  43340. teleportationEnabled: boolean;
  43341. private _defaultHeight;
  43342. private _teleportationInitialized;
  43343. private _interactionsEnabled;
  43344. private _interactionsRequested;
  43345. private _displayGaze;
  43346. private _displayLaserPointer;
  43347. /**
  43348. * The mesh used to display where the user is going to teleport.
  43349. */
  43350. /**
  43351. * Sets the mesh to be used to display where the user is going to teleport.
  43352. */
  43353. teleportationTarget: Mesh;
  43354. /**
  43355. * 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
  43356. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  43357. * See http://doc.babylonjs.com/resources/baking_transformations
  43358. */
  43359. gazeTrackerMesh: Mesh;
  43360. /**
  43361. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  43362. */
  43363. updateGazeTrackerScale: boolean;
  43364. /**
  43365. * If the gaze trackers color should be updated when selecting meshes
  43366. */
  43367. updateGazeTrackerColor: boolean;
  43368. /**
  43369. * If the controller laser color should be updated when selecting meshes
  43370. */
  43371. updateControllerLaserColor: boolean;
  43372. /**
  43373. * The gaze tracking mesh corresponding to the left controller
  43374. */
  43375. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  43376. /**
  43377. * The gaze tracking mesh corresponding to the right controller
  43378. */
  43379. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  43380. /**
  43381. * If the ray of the gaze should be displayed.
  43382. */
  43383. /**
  43384. * Sets if the ray of the gaze should be displayed.
  43385. */
  43386. displayGaze: boolean;
  43387. /**
  43388. * If the ray of the LaserPointer should be displayed.
  43389. */
  43390. /**
  43391. * Sets if the ray of the LaserPointer should be displayed.
  43392. */
  43393. displayLaserPointer: boolean;
  43394. /**
  43395. * The deviceOrientationCamera used as the camera when not in VR.
  43396. */
  43397. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  43398. /**
  43399. * Based on the current WebVR support, returns the current VR camera used.
  43400. */
  43401. readonly currentVRCamera: Nullable<Camera>;
  43402. /**
  43403. * The webVRCamera which is used when in VR.
  43404. */
  43405. readonly webVRCamera: WebVRFreeCamera;
  43406. /**
  43407. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  43408. */
  43409. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  43410. /**
  43411. * The html button that is used to trigger entering into VR.
  43412. */
  43413. readonly vrButton: Nullable<HTMLButtonElement>;
  43414. private readonly _teleportationRequestInitiated;
  43415. /**
  43416. * Defines wether or not Pointer lock should be requested when switching to
  43417. * full screen.
  43418. */
  43419. requestPointerLockOnFullScreen: boolean;
  43420. /**
  43421. * If asking to force XR, this will be populated with the default xr experience
  43422. */
  43423. xr: WebXRDefaultExperience;
  43424. /**
  43425. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  43426. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  43427. */
  43428. xrTestDone: boolean;
  43429. /**
  43430. * Instantiates a VRExperienceHelper.
  43431. * Helps to quickly add VR support to an existing scene.
  43432. * @param scene The scene the VRExperienceHelper belongs to.
  43433. * @param webVROptions Options to modify the vr experience helper's behavior.
  43434. */
  43435. constructor(scene: Scene,
  43436. /** Options to modify the vr experience helper's behavior. */
  43437. webVROptions?: VRExperienceHelperOptions);
  43438. private completeVRInit;
  43439. private _onDefaultMeshLoaded;
  43440. private _onResize;
  43441. private _onFullscreenChange;
  43442. /**
  43443. * Gets a value indicating if we are currently in VR mode.
  43444. */
  43445. readonly isInVRMode: boolean;
  43446. private onVrDisplayPresentChange;
  43447. private onVRDisplayChanged;
  43448. private moveButtonToBottomRight;
  43449. private displayVRButton;
  43450. private updateButtonVisibility;
  43451. private _cachedAngularSensibility;
  43452. /**
  43453. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  43454. * Otherwise, will use the fullscreen API.
  43455. */
  43456. enterVR(): void;
  43457. /**
  43458. * Attempt to exit VR, or fullscreen.
  43459. */
  43460. exitVR(): void;
  43461. /**
  43462. * The position of the vr experience helper.
  43463. */
  43464. /**
  43465. * Sets the position of the vr experience helper.
  43466. */
  43467. position: Vector3;
  43468. /**
  43469. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  43470. */
  43471. enableInteractions(): void;
  43472. private readonly _noControllerIsActive;
  43473. private beforeRender;
  43474. private _isTeleportationFloor;
  43475. /**
  43476. * Adds a floor mesh to be used for teleportation.
  43477. * @param floorMesh the mesh to be used for teleportation.
  43478. */
  43479. addFloorMesh(floorMesh: Mesh): void;
  43480. /**
  43481. * Removes a floor mesh from being used for teleportation.
  43482. * @param floorMesh the mesh to be removed.
  43483. */
  43484. removeFloorMesh(floorMesh: Mesh): void;
  43485. /**
  43486. * Enables interactions and teleportation using the VR controllers and gaze.
  43487. * @param vrTeleportationOptions options to modify teleportation behavior.
  43488. */
  43489. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  43490. private _onNewGamepadConnected;
  43491. private _tryEnableInteractionOnController;
  43492. private _onNewGamepadDisconnected;
  43493. private _enableInteractionOnController;
  43494. private _checkTeleportWithRay;
  43495. private _checkRotate;
  43496. private _checkTeleportBackwards;
  43497. private _enableTeleportationOnController;
  43498. private _createTeleportationCircles;
  43499. private _displayTeleportationTarget;
  43500. private _hideTeleportationTarget;
  43501. private _rotateCamera;
  43502. private _moveTeleportationSelectorTo;
  43503. private _workingVector;
  43504. private _workingQuaternion;
  43505. private _workingMatrix;
  43506. /**
  43507. * Time Constant Teleportation Mode
  43508. */
  43509. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  43510. /**
  43511. * Speed Constant Teleportation Mode
  43512. */
  43513. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  43514. /**
  43515. * Teleports the users feet to the desired location
  43516. * @param location The location where the user's feet should be placed
  43517. */
  43518. teleportCamera(location: Vector3): void;
  43519. private _convertNormalToDirectionOfRay;
  43520. private _castRayAndSelectObject;
  43521. private _notifySelectedMeshUnselected;
  43522. /**
  43523. * Sets the color of the laser ray from the vr controllers.
  43524. * @param color new color for the ray.
  43525. */
  43526. changeLaserColor(color: Color3): void;
  43527. /**
  43528. * Sets the color of the ray from the vr headsets gaze.
  43529. * @param color new color for the ray.
  43530. */
  43531. changeGazeColor(color: Color3): void;
  43532. /**
  43533. * Exits VR and disposes of the vr experience helper
  43534. */
  43535. dispose(): void;
  43536. /**
  43537. * Gets the name of the VRExperienceHelper class
  43538. * @returns "VRExperienceHelper"
  43539. */
  43540. getClassName(): string;
  43541. }
  43542. }
  43543. declare module BABYLON {
  43544. /**
  43545. * Contains an array of blocks representing the octree
  43546. */
  43547. export interface IOctreeContainer<T> {
  43548. /**
  43549. * Blocks within the octree
  43550. */
  43551. blocks: Array<OctreeBlock<T>>;
  43552. }
  43553. /**
  43554. * Class used to store a cell in an octree
  43555. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43556. */
  43557. export class OctreeBlock<T> {
  43558. /**
  43559. * Gets the content of the current block
  43560. */
  43561. entries: T[];
  43562. /**
  43563. * Gets the list of block children
  43564. */
  43565. blocks: Array<OctreeBlock<T>>;
  43566. private _depth;
  43567. private _maxDepth;
  43568. private _capacity;
  43569. private _minPoint;
  43570. private _maxPoint;
  43571. private _boundingVectors;
  43572. private _creationFunc;
  43573. /**
  43574. * Creates a new block
  43575. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43576. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43577. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43578. * @param depth defines the current depth of this block in the octree
  43579. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43580. * @param creationFunc defines a callback to call when an element is added to the block
  43581. */
  43582. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43583. /**
  43584. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43585. */
  43586. readonly capacity: number;
  43587. /**
  43588. * Gets the minimum vector (in world space) of the block's bounding box
  43589. */
  43590. readonly minPoint: Vector3;
  43591. /**
  43592. * Gets the maximum vector (in world space) of the block's bounding box
  43593. */
  43594. readonly maxPoint: Vector3;
  43595. /**
  43596. * Add a new element to this block
  43597. * @param entry defines the element to add
  43598. */
  43599. addEntry(entry: T): void;
  43600. /**
  43601. * Remove an element from this block
  43602. * @param entry defines the element to remove
  43603. */
  43604. removeEntry(entry: T): void;
  43605. /**
  43606. * Add an array of elements to this block
  43607. * @param entries defines the array of elements to add
  43608. */
  43609. addEntries(entries: T[]): void;
  43610. /**
  43611. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43612. * @param frustumPlanes defines the frustum planes to test
  43613. * @param selection defines the array to store current content if selection is positive
  43614. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43615. */
  43616. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43617. /**
  43618. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43619. * @param sphereCenter defines the bounding sphere center
  43620. * @param sphereRadius defines the bounding sphere radius
  43621. * @param selection defines the array to store current content if selection is positive
  43622. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43623. */
  43624. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43625. /**
  43626. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43627. * @param ray defines the ray to test with
  43628. * @param selection defines the array to store current content if selection is positive
  43629. */
  43630. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43631. /**
  43632. * Subdivide the content into child blocks (this block will then be empty)
  43633. */
  43634. createInnerBlocks(): void;
  43635. /**
  43636. * @hidden
  43637. */
  43638. 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;
  43639. }
  43640. }
  43641. declare module BABYLON {
  43642. /**
  43643. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43644. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43645. */
  43646. export class Octree<T> {
  43647. /** 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.) */
  43648. maxDepth: number;
  43649. /**
  43650. * Blocks within the octree containing objects
  43651. */
  43652. blocks: Array<OctreeBlock<T>>;
  43653. /**
  43654. * Content stored in the octree
  43655. */
  43656. dynamicContent: T[];
  43657. private _maxBlockCapacity;
  43658. private _selectionContent;
  43659. private _creationFunc;
  43660. /**
  43661. * Creates a octree
  43662. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43663. * @param creationFunc function to be used to instatiate the octree
  43664. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43665. * @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.)
  43666. */
  43667. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43668. /** 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.) */
  43669. maxDepth?: number);
  43670. /**
  43671. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43672. * @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);
  43673. * @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);
  43674. * @param entries meshes to be added to the octree blocks
  43675. */
  43676. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43677. /**
  43678. * Adds a mesh to the octree
  43679. * @param entry Mesh to add to the octree
  43680. */
  43681. addMesh(entry: T): void;
  43682. /**
  43683. * Remove an element from the octree
  43684. * @param entry defines the element to remove
  43685. */
  43686. removeMesh(entry: T): void;
  43687. /**
  43688. * Selects an array of meshes within the frustum
  43689. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43690. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43691. * @returns array of meshes within the frustum
  43692. */
  43693. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43694. /**
  43695. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43696. * @param sphereCenter defines the bounding sphere center
  43697. * @param sphereRadius defines the bounding sphere radius
  43698. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43699. * @returns an array of objects that intersect the sphere
  43700. */
  43701. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43702. /**
  43703. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43704. * @param ray defines the ray to test with
  43705. * @returns array of intersected objects
  43706. */
  43707. intersectsRay(ray: Ray): SmartArray<T>;
  43708. /**
  43709. * Adds a mesh into the octree block if it intersects the block
  43710. */
  43711. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43712. /**
  43713. * Adds a submesh into the octree block if it intersects the block
  43714. */
  43715. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43716. }
  43717. }
  43718. declare module BABYLON {
  43719. interface Scene {
  43720. /**
  43721. * @hidden
  43722. * Backing Filed
  43723. */
  43724. _selectionOctree: Octree<AbstractMesh>;
  43725. /**
  43726. * Gets the octree used to boost mesh selection (picking)
  43727. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43728. */
  43729. selectionOctree: Octree<AbstractMesh>;
  43730. /**
  43731. * Creates or updates the octree used to boost selection (picking)
  43732. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43733. * @param maxCapacity defines the maximum capacity per leaf
  43734. * @param maxDepth defines the maximum depth of the octree
  43735. * @returns an octree of AbstractMesh
  43736. */
  43737. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43738. }
  43739. interface AbstractMesh {
  43740. /**
  43741. * @hidden
  43742. * Backing Field
  43743. */
  43744. _submeshesOctree: Octree<SubMesh>;
  43745. /**
  43746. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43747. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43748. * @param maxCapacity defines the maximum size of each block (64 by default)
  43749. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43750. * @returns the new octree
  43751. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43752. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43753. */
  43754. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43755. }
  43756. /**
  43757. * Defines the octree scene component responsible to manage any octrees
  43758. * in a given scene.
  43759. */
  43760. export class OctreeSceneComponent {
  43761. /**
  43762. * The component name help to identify the component in the list of scene components.
  43763. */
  43764. readonly name: string;
  43765. /**
  43766. * The scene the component belongs to.
  43767. */
  43768. scene: Scene;
  43769. /**
  43770. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43771. */
  43772. readonly checksIsEnabled: boolean;
  43773. /**
  43774. * Creates a new instance of the component for the given scene
  43775. * @param scene Defines the scene to register the component in
  43776. */
  43777. constructor(scene: Scene);
  43778. /**
  43779. * Registers the component in a given scene
  43780. */
  43781. register(): void;
  43782. /**
  43783. * Return the list of active meshes
  43784. * @returns the list of active meshes
  43785. */
  43786. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43787. /**
  43788. * Return the list of active sub meshes
  43789. * @param mesh The mesh to get the candidates sub meshes from
  43790. * @returns the list of active sub meshes
  43791. */
  43792. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43793. private _tempRay;
  43794. /**
  43795. * Return the list of sub meshes intersecting with a given local ray
  43796. * @param mesh defines the mesh to find the submesh for
  43797. * @param localRay defines the ray in local space
  43798. * @returns the list of intersecting sub meshes
  43799. */
  43800. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43801. /**
  43802. * Return the list of sub meshes colliding with a collider
  43803. * @param mesh defines the mesh to find the submesh for
  43804. * @param collider defines the collider to evaluate the collision against
  43805. * @returns the list of colliding sub meshes
  43806. */
  43807. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43808. /**
  43809. * Rebuilds the elements related to this component in case of
  43810. * context lost for instance.
  43811. */
  43812. rebuild(): void;
  43813. /**
  43814. * Disposes the component and the associated ressources.
  43815. */
  43816. dispose(): void;
  43817. }
  43818. }
  43819. declare module BABYLON {
  43820. /**
  43821. * Renders a layer on top of an existing scene
  43822. */
  43823. export class UtilityLayerRenderer implements IDisposable {
  43824. /** the original scene that will be rendered on top of */
  43825. originalScene: Scene;
  43826. private _pointerCaptures;
  43827. private _lastPointerEvents;
  43828. private static _DefaultUtilityLayer;
  43829. private static _DefaultKeepDepthUtilityLayer;
  43830. private _sharedGizmoLight;
  43831. private _renderCamera;
  43832. /**
  43833. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  43834. * @returns the camera that is used when rendering the utility layer
  43835. */
  43836. getRenderCamera(): Nullable<Camera>;
  43837. /**
  43838. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  43839. * @param cam the camera that should be used when rendering the utility layer
  43840. */
  43841. setRenderCamera(cam: Nullable<Camera>): void;
  43842. /**
  43843. * @hidden
  43844. * Light which used by gizmos to get light shading
  43845. */
  43846. _getSharedGizmoLight(): HemisphericLight;
  43847. /**
  43848. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  43849. */
  43850. pickUtilitySceneFirst: boolean;
  43851. /**
  43852. * 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)
  43853. */
  43854. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  43855. /**
  43856. * 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)
  43857. */
  43858. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  43859. /**
  43860. * The scene that is rendered on top of the original scene
  43861. */
  43862. utilityLayerScene: Scene;
  43863. /**
  43864. * If the utility layer should automatically be rendered on top of existing scene
  43865. */
  43866. shouldRender: boolean;
  43867. /**
  43868. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  43869. */
  43870. onlyCheckPointerDownEvents: boolean;
  43871. /**
  43872. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  43873. */
  43874. processAllEvents: boolean;
  43875. /**
  43876. * Observable raised when the pointer move from the utility layer scene to the main scene
  43877. */
  43878. onPointerOutObservable: Observable<number>;
  43879. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  43880. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  43881. private _afterRenderObserver;
  43882. private _sceneDisposeObserver;
  43883. private _originalPointerObserver;
  43884. /**
  43885. * Instantiates a UtilityLayerRenderer
  43886. * @param originalScene the original scene that will be rendered on top of
  43887. * @param handleEvents boolean indicating if the utility layer should handle events
  43888. */
  43889. constructor(
  43890. /** the original scene that will be rendered on top of */
  43891. originalScene: Scene, handleEvents?: boolean);
  43892. private _notifyObservers;
  43893. /**
  43894. * Renders the utility layers scene on top of the original scene
  43895. */
  43896. render(): void;
  43897. /**
  43898. * Disposes of the renderer
  43899. */
  43900. dispose(): void;
  43901. private _updateCamera;
  43902. }
  43903. }
  43904. declare module BABYLON {
  43905. /**
  43906. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  43907. */
  43908. export class Gizmo implements IDisposable {
  43909. /** The utility layer the gizmo will be added to */
  43910. gizmoLayer: UtilityLayerRenderer;
  43911. /**
  43912. * The root mesh of the gizmo
  43913. */
  43914. _rootMesh: Mesh;
  43915. private _attachedMesh;
  43916. /**
  43917. * Ratio for the scale of the gizmo (Default: 1)
  43918. */
  43919. scaleRatio: number;
  43920. /**
  43921. * If a custom mesh has been set (Default: false)
  43922. */
  43923. protected _customMeshSet: boolean;
  43924. /**
  43925. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  43926. * * When set, interactions will be enabled
  43927. */
  43928. attachedMesh: Nullable<AbstractMesh>;
  43929. /**
  43930. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43931. * @param mesh The mesh to replace the default mesh of the gizmo
  43932. */
  43933. setCustomMesh(mesh: Mesh): void;
  43934. /**
  43935. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  43936. */
  43937. updateGizmoRotationToMatchAttachedMesh: boolean;
  43938. /**
  43939. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  43940. */
  43941. updateGizmoPositionToMatchAttachedMesh: boolean;
  43942. /**
  43943. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  43944. */
  43945. updateScale: boolean;
  43946. protected _interactionsEnabled: boolean;
  43947. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43948. private _beforeRenderObserver;
  43949. private _tempVector;
  43950. /**
  43951. * Creates a gizmo
  43952. * @param gizmoLayer The utility layer the gizmo will be added to
  43953. */
  43954. constructor(
  43955. /** The utility layer the gizmo will be added to */
  43956. gizmoLayer?: UtilityLayerRenderer);
  43957. /**
  43958. * Updates the gizmo to match the attached mesh's position/rotation
  43959. */
  43960. protected _update(): void;
  43961. /**
  43962. * Disposes of the gizmo
  43963. */
  43964. dispose(): void;
  43965. }
  43966. }
  43967. declare module BABYLON {
  43968. /**
  43969. * Single plane drag gizmo
  43970. */
  43971. export class PlaneDragGizmo extends Gizmo {
  43972. /**
  43973. * Drag behavior responsible for the gizmos dragging interactions
  43974. */
  43975. dragBehavior: PointerDragBehavior;
  43976. private _pointerObserver;
  43977. /**
  43978. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43979. */
  43980. snapDistance: number;
  43981. /**
  43982. * Event that fires each time the gizmo snaps to a new location.
  43983. * * snapDistance is the the change in distance
  43984. */
  43985. onSnapObservable: Observable<{
  43986. snapDistance: number;
  43987. }>;
  43988. private _plane;
  43989. private _coloredMaterial;
  43990. private _hoverMaterial;
  43991. private _isEnabled;
  43992. private _parent;
  43993. /** @hidden */
  43994. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  43995. /** @hidden */
  43996. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43997. /**
  43998. * Creates a PlaneDragGizmo
  43999. * @param gizmoLayer The utility layer the gizmo will be added to
  44000. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44001. * @param color The color of the gizmo
  44002. */
  44003. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44004. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44005. /**
  44006. * If the gizmo is enabled
  44007. */
  44008. isEnabled: boolean;
  44009. /**
  44010. * Disposes of the gizmo
  44011. */
  44012. dispose(): void;
  44013. }
  44014. }
  44015. declare module BABYLON {
  44016. /**
  44017. * Gizmo that enables dragging a mesh along 3 axis
  44018. */
  44019. export class PositionGizmo extends Gizmo {
  44020. /**
  44021. * Internal gizmo used for interactions on the x axis
  44022. */
  44023. xGizmo: AxisDragGizmo;
  44024. /**
  44025. * Internal gizmo used for interactions on the y axis
  44026. */
  44027. yGizmo: AxisDragGizmo;
  44028. /**
  44029. * Internal gizmo used for interactions on the z axis
  44030. */
  44031. zGizmo: AxisDragGizmo;
  44032. /**
  44033. * Internal gizmo used for interactions on the yz plane
  44034. */
  44035. xPlaneGizmo: PlaneDragGizmo;
  44036. /**
  44037. * Internal gizmo used for interactions on the xz plane
  44038. */
  44039. yPlaneGizmo: PlaneDragGizmo;
  44040. /**
  44041. * Internal gizmo used for interactions on the xy plane
  44042. */
  44043. zPlaneGizmo: PlaneDragGizmo;
  44044. /**
  44045. * private variables
  44046. */
  44047. private _meshAttached;
  44048. private _updateGizmoRotationToMatchAttachedMesh;
  44049. private _snapDistance;
  44050. private _scaleRatio;
  44051. /** Fires an event when any of it's sub gizmos are dragged */
  44052. onDragStartObservable: Observable<unknown>;
  44053. /** Fires an event when any of it's sub gizmos are released from dragging */
  44054. onDragEndObservable: Observable<unknown>;
  44055. /**
  44056. * If set to true, planar drag is enabled
  44057. */
  44058. private _planarGizmoEnabled;
  44059. attachedMesh: Nullable<AbstractMesh>;
  44060. /**
  44061. * Creates a PositionGizmo
  44062. * @param gizmoLayer The utility layer the gizmo will be added to
  44063. */
  44064. constructor(gizmoLayer?: UtilityLayerRenderer);
  44065. /**
  44066. * If the planar drag gizmo is enabled
  44067. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44068. */
  44069. planarGizmoEnabled: boolean;
  44070. updateGizmoRotationToMatchAttachedMesh: boolean;
  44071. /**
  44072. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44073. */
  44074. snapDistance: number;
  44075. /**
  44076. * Ratio for the scale of the gizmo (Default: 1)
  44077. */
  44078. scaleRatio: number;
  44079. /**
  44080. * Disposes of the gizmo
  44081. */
  44082. dispose(): void;
  44083. /**
  44084. * CustomMeshes are not supported by this gizmo
  44085. * @param mesh The mesh to replace the default mesh of the gizmo
  44086. */
  44087. setCustomMesh(mesh: Mesh): void;
  44088. }
  44089. }
  44090. declare module BABYLON {
  44091. /**
  44092. * Single axis drag gizmo
  44093. */
  44094. export class AxisDragGizmo extends Gizmo {
  44095. /**
  44096. * Drag behavior responsible for the gizmos dragging interactions
  44097. */
  44098. dragBehavior: PointerDragBehavior;
  44099. private _pointerObserver;
  44100. /**
  44101. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44102. */
  44103. snapDistance: number;
  44104. /**
  44105. * Event that fires each time the gizmo snaps to a new location.
  44106. * * snapDistance is the the change in distance
  44107. */
  44108. onSnapObservable: Observable<{
  44109. snapDistance: number;
  44110. }>;
  44111. private _isEnabled;
  44112. private _parent;
  44113. private _arrow;
  44114. private _coloredMaterial;
  44115. private _hoverMaterial;
  44116. /** @hidden */
  44117. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44118. /** @hidden */
  44119. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44120. /**
  44121. * Creates an AxisDragGizmo
  44122. * @param gizmoLayer The utility layer the gizmo will be added to
  44123. * @param dragAxis The axis which the gizmo will be able to drag on
  44124. * @param color The color of the gizmo
  44125. */
  44126. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44127. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44128. /**
  44129. * If the gizmo is enabled
  44130. */
  44131. isEnabled: boolean;
  44132. /**
  44133. * Disposes of the gizmo
  44134. */
  44135. dispose(): void;
  44136. }
  44137. }
  44138. declare module BABYLON.Debug {
  44139. /**
  44140. * The Axes viewer will show 3 axes in a specific point in space
  44141. */
  44142. export class AxesViewer {
  44143. private _xAxis;
  44144. private _yAxis;
  44145. private _zAxis;
  44146. private _scaleLinesFactor;
  44147. private _instanced;
  44148. /**
  44149. * Gets the hosting scene
  44150. */
  44151. scene: Scene;
  44152. /**
  44153. * Gets or sets a number used to scale line length
  44154. */
  44155. scaleLines: number;
  44156. /** Gets the node hierarchy used to render x-axis */
  44157. readonly xAxis: TransformNode;
  44158. /** Gets the node hierarchy used to render y-axis */
  44159. readonly yAxis: TransformNode;
  44160. /** Gets the node hierarchy used to render z-axis */
  44161. readonly zAxis: TransformNode;
  44162. /**
  44163. * Creates a new AxesViewer
  44164. * @param scene defines the hosting scene
  44165. * @param scaleLines defines a number used to scale line length (1 by default)
  44166. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44167. * @param xAxis defines the node hierarchy used to render the x-axis
  44168. * @param yAxis defines the node hierarchy used to render the y-axis
  44169. * @param zAxis defines the node hierarchy used to render the z-axis
  44170. */
  44171. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44172. /**
  44173. * Force the viewer to update
  44174. * @param position defines the position of the viewer
  44175. * @param xaxis defines the x axis of the viewer
  44176. * @param yaxis defines the y axis of the viewer
  44177. * @param zaxis defines the z axis of the viewer
  44178. */
  44179. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44180. /**
  44181. * Creates an instance of this axes viewer.
  44182. * @returns a new axes viewer with instanced meshes
  44183. */
  44184. createInstance(): AxesViewer;
  44185. /** Releases resources */
  44186. dispose(): void;
  44187. private static _SetRenderingGroupId;
  44188. }
  44189. }
  44190. declare module BABYLON.Debug {
  44191. /**
  44192. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44193. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44194. */
  44195. export class BoneAxesViewer extends AxesViewer {
  44196. /**
  44197. * Gets or sets the target mesh where to display the axes viewer
  44198. */
  44199. mesh: Nullable<Mesh>;
  44200. /**
  44201. * Gets or sets the target bone where to display the axes viewer
  44202. */
  44203. bone: Nullable<Bone>;
  44204. /** Gets current position */
  44205. pos: Vector3;
  44206. /** Gets direction of X axis */
  44207. xaxis: Vector3;
  44208. /** Gets direction of Y axis */
  44209. yaxis: Vector3;
  44210. /** Gets direction of Z axis */
  44211. zaxis: Vector3;
  44212. /**
  44213. * Creates a new BoneAxesViewer
  44214. * @param scene defines the hosting scene
  44215. * @param bone defines the target bone
  44216. * @param mesh defines the target mesh
  44217. * @param scaleLines defines a scaling factor for line length (1 by default)
  44218. */
  44219. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44220. /**
  44221. * Force the viewer to update
  44222. */
  44223. update(): void;
  44224. /** Releases resources */
  44225. dispose(): void;
  44226. }
  44227. }
  44228. declare module BABYLON {
  44229. /**
  44230. * Interface used to define scene explorer extensibility option
  44231. */
  44232. export interface IExplorerExtensibilityOption {
  44233. /**
  44234. * Define the option label
  44235. */
  44236. label: string;
  44237. /**
  44238. * Defines the action to execute on click
  44239. */
  44240. action: (entity: any) => void;
  44241. }
  44242. /**
  44243. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44244. */
  44245. export interface IExplorerExtensibilityGroup {
  44246. /**
  44247. * Defines a predicate to test if a given type mut be extended
  44248. */
  44249. predicate: (entity: any) => boolean;
  44250. /**
  44251. * Gets the list of options added to a type
  44252. */
  44253. entries: IExplorerExtensibilityOption[];
  44254. }
  44255. /**
  44256. * Interface used to define the options to use to create the Inspector
  44257. */
  44258. export interface IInspectorOptions {
  44259. /**
  44260. * Display in overlay mode (default: false)
  44261. */
  44262. overlay?: boolean;
  44263. /**
  44264. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44265. */
  44266. globalRoot?: HTMLElement;
  44267. /**
  44268. * Display the Scene explorer
  44269. */
  44270. showExplorer?: boolean;
  44271. /**
  44272. * Display the property inspector
  44273. */
  44274. showInspector?: boolean;
  44275. /**
  44276. * Display in embed mode (both panes on the right)
  44277. */
  44278. embedMode?: boolean;
  44279. /**
  44280. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44281. */
  44282. handleResize?: boolean;
  44283. /**
  44284. * Allow the panes to popup (default: true)
  44285. */
  44286. enablePopup?: boolean;
  44287. /**
  44288. * Allow the panes to be closed by users (default: true)
  44289. */
  44290. enableClose?: boolean;
  44291. /**
  44292. * Optional list of extensibility entries
  44293. */
  44294. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44295. /**
  44296. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44297. */
  44298. inspectorURL?: string;
  44299. /**
  44300. * Optional initial tab (default to DebugLayerTab.Properties)
  44301. */
  44302. initialTab?: DebugLayerTab;
  44303. }
  44304. interface Scene {
  44305. /**
  44306. * @hidden
  44307. * Backing field
  44308. */
  44309. _debugLayer: DebugLayer;
  44310. /**
  44311. * Gets the debug layer (aka Inspector) associated with the scene
  44312. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44313. */
  44314. debugLayer: DebugLayer;
  44315. }
  44316. /**
  44317. * Enum of inspector action tab
  44318. */
  44319. export enum DebugLayerTab {
  44320. /**
  44321. * Properties tag (default)
  44322. */
  44323. Properties = 0,
  44324. /**
  44325. * Debug tab
  44326. */
  44327. Debug = 1,
  44328. /**
  44329. * Statistics tab
  44330. */
  44331. Statistics = 2,
  44332. /**
  44333. * Tools tab
  44334. */
  44335. Tools = 3,
  44336. /**
  44337. * Settings tab
  44338. */
  44339. Settings = 4
  44340. }
  44341. /**
  44342. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44343. * what is happening in your scene
  44344. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44345. */
  44346. export class DebugLayer {
  44347. /**
  44348. * Define the url to get the inspector script from.
  44349. * By default it uses the babylonjs CDN.
  44350. * @ignoreNaming
  44351. */
  44352. static InspectorURL: string;
  44353. private _scene;
  44354. private BJSINSPECTOR;
  44355. private _onPropertyChangedObservable?;
  44356. /**
  44357. * Observable triggered when a property is changed through the inspector.
  44358. */
  44359. readonly onPropertyChangedObservable: any;
  44360. /**
  44361. * Instantiates a new debug layer.
  44362. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44363. * what is happening in your scene
  44364. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44365. * @param scene Defines the scene to inspect
  44366. */
  44367. constructor(scene: Scene);
  44368. /** Creates the inspector window. */
  44369. private _createInspector;
  44370. /**
  44371. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44372. * @param entity defines the entity to select
  44373. * @param lineContainerTitle defines the specific block to highlight
  44374. */
  44375. select(entity: any, lineContainerTitle?: string): void;
  44376. /** Get the inspector from bundle or global */
  44377. private _getGlobalInspector;
  44378. /**
  44379. * Get if the inspector is visible or not.
  44380. * @returns true if visible otherwise, false
  44381. */
  44382. isVisible(): boolean;
  44383. /**
  44384. * Hide the inspector and close its window.
  44385. */
  44386. hide(): void;
  44387. /**
  44388. * Launch the debugLayer.
  44389. * @param config Define the configuration of the inspector
  44390. * @return a promise fulfilled when the debug layer is visible
  44391. */
  44392. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44393. }
  44394. }
  44395. declare module BABYLON {
  44396. /**
  44397. * Class containing static functions to help procedurally build meshes
  44398. */
  44399. export class BoxBuilder {
  44400. /**
  44401. * Creates a box mesh
  44402. * * The parameter `size` sets the size (float) of each box side (default 1)
  44403. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44404. * * 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)
  44405. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44406. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44407. * * 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
  44408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44409. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44410. * @param name defines the name of the mesh
  44411. * @param options defines the options used to create the mesh
  44412. * @param scene defines the hosting scene
  44413. * @returns the box mesh
  44414. */
  44415. static CreateBox(name: string, options: {
  44416. size?: number;
  44417. width?: number;
  44418. height?: number;
  44419. depth?: number;
  44420. faceUV?: Vector4[];
  44421. faceColors?: Color4[];
  44422. sideOrientation?: number;
  44423. frontUVs?: Vector4;
  44424. backUVs?: Vector4;
  44425. wrap?: boolean;
  44426. topBaseAt?: number;
  44427. bottomBaseAt?: number;
  44428. updatable?: boolean;
  44429. }, scene?: Nullable<Scene>): Mesh;
  44430. }
  44431. }
  44432. declare module BABYLON {
  44433. /**
  44434. * Class containing static functions to help procedurally build meshes
  44435. */
  44436. export class SphereBuilder {
  44437. /**
  44438. * Creates a sphere mesh
  44439. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44440. * * 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`)
  44441. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44442. * * 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
  44443. * * 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)
  44444. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44445. * * 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
  44446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44447. * @param name defines the name of the mesh
  44448. * @param options defines the options used to create the mesh
  44449. * @param scene defines the hosting scene
  44450. * @returns the sphere mesh
  44451. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44452. */
  44453. static CreateSphere(name: string, options: {
  44454. segments?: number;
  44455. diameter?: number;
  44456. diameterX?: number;
  44457. diameterY?: number;
  44458. diameterZ?: number;
  44459. arc?: number;
  44460. slice?: number;
  44461. sideOrientation?: number;
  44462. frontUVs?: Vector4;
  44463. backUVs?: Vector4;
  44464. updatable?: boolean;
  44465. }, scene?: Nullable<Scene>): Mesh;
  44466. }
  44467. }
  44468. declare module BABYLON.Debug {
  44469. /**
  44470. * Used to show the physics impostor around the specific mesh
  44471. */
  44472. export class PhysicsViewer {
  44473. /** @hidden */
  44474. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44475. /** @hidden */
  44476. protected _meshes: Array<Nullable<AbstractMesh>>;
  44477. /** @hidden */
  44478. protected _scene: Nullable<Scene>;
  44479. /** @hidden */
  44480. protected _numMeshes: number;
  44481. /** @hidden */
  44482. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44483. private _renderFunction;
  44484. private _utilityLayer;
  44485. private _debugBoxMesh;
  44486. private _debugSphereMesh;
  44487. private _debugCylinderMesh;
  44488. private _debugMaterial;
  44489. private _debugMeshMeshes;
  44490. /**
  44491. * Creates a new PhysicsViewer
  44492. * @param scene defines the hosting scene
  44493. */
  44494. constructor(scene: Scene);
  44495. /** @hidden */
  44496. protected _updateDebugMeshes(): void;
  44497. /**
  44498. * Renders a specified physic impostor
  44499. * @param impostor defines the impostor to render
  44500. * @param targetMesh defines the mesh represented by the impostor
  44501. * @returns the new debug mesh used to render the impostor
  44502. */
  44503. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44504. /**
  44505. * Hides a specified physic impostor
  44506. * @param impostor defines the impostor to hide
  44507. */
  44508. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44509. private _getDebugMaterial;
  44510. private _getDebugBoxMesh;
  44511. private _getDebugSphereMesh;
  44512. private _getDebugCylinderMesh;
  44513. private _getDebugMeshMesh;
  44514. private _getDebugMesh;
  44515. /** Releases all resources */
  44516. dispose(): void;
  44517. }
  44518. }
  44519. declare module BABYLON {
  44520. /**
  44521. * Class containing static functions to help procedurally build meshes
  44522. */
  44523. export class LinesBuilder {
  44524. /**
  44525. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44526. * * 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
  44527. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44528. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44529. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44530. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44531. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44532. * * 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
  44533. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44535. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44536. * @param name defines the name of the new line system
  44537. * @param options defines the options used to create the line system
  44538. * @param scene defines the hosting scene
  44539. * @returns a new line system mesh
  44540. */
  44541. static CreateLineSystem(name: string, options: {
  44542. lines: Vector3[][];
  44543. updatable?: boolean;
  44544. instance?: Nullable<LinesMesh>;
  44545. colors?: Nullable<Color4[][]>;
  44546. useVertexAlpha?: boolean;
  44547. }, scene: Nullable<Scene>): LinesMesh;
  44548. /**
  44549. * Creates a line mesh
  44550. * 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
  44551. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44552. * * The parameter `points` is an array successive Vector3
  44553. * * 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
  44554. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44555. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44556. * * When updating an instance, remember that only point positions can change, not the number of points
  44557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44558. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44559. * @param name defines the name of the new line system
  44560. * @param options defines the options used to create the line system
  44561. * @param scene defines the hosting scene
  44562. * @returns a new line mesh
  44563. */
  44564. static CreateLines(name: string, options: {
  44565. points: Vector3[];
  44566. updatable?: boolean;
  44567. instance?: Nullable<LinesMesh>;
  44568. colors?: Color4[];
  44569. useVertexAlpha?: boolean;
  44570. }, scene?: Nullable<Scene>): LinesMesh;
  44571. /**
  44572. * Creates a dashed line mesh
  44573. * * 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
  44574. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44575. * * The parameter `points` is an array successive Vector3
  44576. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44577. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44578. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44579. * * 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
  44580. * * When updating an instance, remember that only point positions can change, not the number of points
  44581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44582. * @param name defines the name of the mesh
  44583. * @param options defines the options used to create the mesh
  44584. * @param scene defines the hosting scene
  44585. * @returns the dashed line mesh
  44586. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44587. */
  44588. static CreateDashedLines(name: string, options: {
  44589. points: Vector3[];
  44590. dashSize?: number;
  44591. gapSize?: number;
  44592. dashNb?: number;
  44593. updatable?: boolean;
  44594. instance?: LinesMesh;
  44595. }, scene?: Nullable<Scene>): LinesMesh;
  44596. }
  44597. }
  44598. declare module BABYLON {
  44599. /**
  44600. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44601. * in order to better appreciate the issue one might have.
  44602. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44603. */
  44604. export class RayHelper {
  44605. /**
  44606. * Defines the ray we are currently tryin to visualize.
  44607. */
  44608. ray: Nullable<Ray>;
  44609. private _renderPoints;
  44610. private _renderLine;
  44611. private _renderFunction;
  44612. private _scene;
  44613. private _updateToMeshFunction;
  44614. private _attachedToMesh;
  44615. private _meshSpaceDirection;
  44616. private _meshSpaceOrigin;
  44617. /**
  44618. * Helper function to create a colored helper in a scene in one line.
  44619. * @param ray Defines the ray we are currently tryin to visualize
  44620. * @param scene Defines the scene the ray is used in
  44621. * @param color Defines the color we want to see the ray in
  44622. * @returns The newly created ray helper.
  44623. */
  44624. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44625. /**
  44626. * Instantiate a new ray helper.
  44627. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44628. * in order to better appreciate the issue one might have.
  44629. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44630. * @param ray Defines the ray we are currently tryin to visualize
  44631. */
  44632. constructor(ray: Ray);
  44633. /**
  44634. * Shows the ray we are willing to debug.
  44635. * @param scene Defines the scene the ray needs to be rendered in
  44636. * @param color Defines the color the ray needs to be rendered in
  44637. */
  44638. show(scene: Scene, color?: Color3): void;
  44639. /**
  44640. * Hides the ray we are debugging.
  44641. */
  44642. hide(): void;
  44643. private _render;
  44644. /**
  44645. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44646. * @param mesh Defines the mesh we want the helper attached to
  44647. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44648. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44649. * @param length Defines the length of the ray
  44650. */
  44651. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44652. /**
  44653. * Detach the ray helper from the mesh it has previously been attached to.
  44654. */
  44655. detachFromMesh(): void;
  44656. private _updateToMesh;
  44657. /**
  44658. * Dispose the helper and release its associated resources.
  44659. */
  44660. dispose(): void;
  44661. }
  44662. }
  44663. declare module BABYLON.Debug {
  44664. /**
  44665. * Class used to render a debug view of a given skeleton
  44666. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  44667. */
  44668. export class SkeletonViewer {
  44669. /** defines the skeleton to render */
  44670. skeleton: Skeleton;
  44671. /** defines the mesh attached to the skeleton */
  44672. mesh: AbstractMesh;
  44673. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44674. autoUpdateBonesMatrices: boolean;
  44675. /** defines the rendering group id to use with the viewer */
  44676. renderingGroupId: number;
  44677. /** Gets or sets the color used to render the skeleton */
  44678. color: Color3;
  44679. private _scene;
  44680. private _debugLines;
  44681. private _debugMesh;
  44682. private _isEnabled;
  44683. private _renderFunction;
  44684. private _utilityLayer;
  44685. /**
  44686. * Returns the mesh used to render the bones
  44687. */
  44688. readonly debugMesh: Nullable<LinesMesh>;
  44689. /**
  44690. * Creates a new SkeletonViewer
  44691. * @param skeleton defines the skeleton to render
  44692. * @param mesh defines the mesh attached to the skeleton
  44693. * @param scene defines the hosting scene
  44694. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  44695. * @param renderingGroupId defines the rendering group id to use with the viewer
  44696. */
  44697. constructor(
  44698. /** defines the skeleton to render */
  44699. skeleton: Skeleton,
  44700. /** defines the mesh attached to the skeleton */
  44701. mesh: AbstractMesh, scene: Scene,
  44702. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44703. autoUpdateBonesMatrices?: boolean,
  44704. /** defines the rendering group id to use with the viewer */
  44705. renderingGroupId?: number);
  44706. /** Gets or sets a boolean indicating if the viewer is enabled */
  44707. isEnabled: boolean;
  44708. private _getBonePosition;
  44709. private _getLinesForBonesWithLength;
  44710. private _getLinesForBonesNoLength;
  44711. /** Update the viewer to sync with current skeleton state */
  44712. update(): void;
  44713. /** Release associated resources */
  44714. dispose(): void;
  44715. }
  44716. }
  44717. declare module BABYLON {
  44718. /**
  44719. * Options to create the null engine
  44720. */
  44721. export class NullEngineOptions {
  44722. /**
  44723. * Render width (Default: 512)
  44724. */
  44725. renderWidth: number;
  44726. /**
  44727. * Render height (Default: 256)
  44728. */
  44729. renderHeight: number;
  44730. /**
  44731. * Texture size (Default: 512)
  44732. */
  44733. textureSize: number;
  44734. /**
  44735. * If delta time between frames should be constant
  44736. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44737. */
  44738. deterministicLockstep: boolean;
  44739. /**
  44740. * Maximum about of steps between frames (Default: 4)
  44741. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44742. */
  44743. lockstepMaxSteps: number;
  44744. }
  44745. /**
  44746. * The null engine class provides support for headless version of babylon.js.
  44747. * This can be used in server side scenario or for testing purposes
  44748. */
  44749. export class NullEngine extends Engine {
  44750. private _options;
  44751. /**
  44752. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  44753. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44754. * @returns true if engine is in deterministic lock step mode
  44755. */
  44756. isDeterministicLockStep(): boolean;
  44757. /**
  44758. * Gets the max steps when engine is running in deterministic lock step
  44759. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44760. * @returns the max steps
  44761. */
  44762. getLockstepMaxSteps(): number;
  44763. /**
  44764. * Gets the current hardware scaling level.
  44765. * By default the hardware scaling level is computed from the window device ratio.
  44766. * 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.
  44767. * @returns a number indicating the current hardware scaling level
  44768. */
  44769. getHardwareScalingLevel(): number;
  44770. constructor(options?: NullEngineOptions);
  44771. /**
  44772. * Creates a vertex buffer
  44773. * @param vertices the data for the vertex buffer
  44774. * @returns the new WebGL static buffer
  44775. */
  44776. createVertexBuffer(vertices: FloatArray): DataBuffer;
  44777. /**
  44778. * Creates a new index buffer
  44779. * @param indices defines the content of the index buffer
  44780. * @param updatable defines if the index buffer must be updatable
  44781. * @returns a new webGL buffer
  44782. */
  44783. createIndexBuffer(indices: IndicesArray): DataBuffer;
  44784. /**
  44785. * Clear the current render buffer or the current render target (if any is set up)
  44786. * @param color defines the color to use
  44787. * @param backBuffer defines if the back buffer must be cleared
  44788. * @param depth defines if the depth buffer must be cleared
  44789. * @param stencil defines if the stencil buffer must be cleared
  44790. */
  44791. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44792. /**
  44793. * Gets the current render width
  44794. * @param useScreen defines if screen size must be used (or the current render target if any)
  44795. * @returns a number defining the current render width
  44796. */
  44797. getRenderWidth(useScreen?: boolean): number;
  44798. /**
  44799. * Gets the current render height
  44800. * @param useScreen defines if screen size must be used (or the current render target if any)
  44801. * @returns a number defining the current render height
  44802. */
  44803. getRenderHeight(useScreen?: boolean): number;
  44804. /**
  44805. * Set the WebGL's viewport
  44806. * @param viewport defines the viewport element to be used
  44807. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  44808. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  44809. */
  44810. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  44811. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  44812. /**
  44813. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  44814. * @param pipelineContext defines the pipeline context to use
  44815. * @param uniformsNames defines the list of uniform names
  44816. * @returns an array of webGL uniform locations
  44817. */
  44818. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  44819. /**
  44820. * Gets the lsit of active attributes for a given webGL program
  44821. * @param pipelineContext defines the pipeline context to use
  44822. * @param attributesNames defines the list of attribute names to get
  44823. * @returns an array of indices indicating the offset of each attribute
  44824. */
  44825. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44826. /**
  44827. * Binds an effect to the webGL context
  44828. * @param effect defines the effect to bind
  44829. */
  44830. bindSamplers(effect: Effect): void;
  44831. /**
  44832. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  44833. * @param effect defines the effect to activate
  44834. */
  44835. enableEffect(effect: Effect): void;
  44836. /**
  44837. * Set various states to the webGL context
  44838. * @param culling defines backface culling state
  44839. * @param zOffset defines the value to apply to zOffset (0 by default)
  44840. * @param force defines if states must be applied even if cache is up to date
  44841. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  44842. */
  44843. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44844. /**
  44845. * Set the value of an uniform to an array of int32
  44846. * @param uniform defines the webGL uniform location where to store the value
  44847. * @param array defines the array of int32 to store
  44848. */
  44849. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44850. /**
  44851. * Set the value of an uniform to an array of int32 (stored as vec2)
  44852. * @param uniform defines the webGL uniform location where to store the value
  44853. * @param array defines the array of int32 to store
  44854. */
  44855. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44856. /**
  44857. * Set the value of an uniform to an array of int32 (stored as vec3)
  44858. * @param uniform defines the webGL uniform location where to store the value
  44859. * @param array defines the array of int32 to store
  44860. */
  44861. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44862. /**
  44863. * Set the value of an uniform to an array of int32 (stored as vec4)
  44864. * @param uniform defines the webGL uniform location where to store the value
  44865. * @param array defines the array of int32 to store
  44866. */
  44867. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44868. /**
  44869. * Set the value of an uniform to an array of float32
  44870. * @param uniform defines the webGL uniform location where to store the value
  44871. * @param array defines the array of float32 to store
  44872. */
  44873. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44874. /**
  44875. * Set the value of an uniform to an array of float32 (stored as vec2)
  44876. * @param uniform defines the webGL uniform location where to store the value
  44877. * @param array defines the array of float32 to store
  44878. */
  44879. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44880. /**
  44881. * Set the value of an uniform to an array of float32 (stored as vec3)
  44882. * @param uniform defines the webGL uniform location where to store the value
  44883. * @param array defines the array of float32 to store
  44884. */
  44885. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44886. /**
  44887. * Set the value of an uniform to an array of float32 (stored as vec4)
  44888. * @param uniform defines the webGL uniform location where to store the value
  44889. * @param array defines the array of float32 to store
  44890. */
  44891. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44892. /**
  44893. * Set the value of an uniform to an array of number
  44894. * @param uniform defines the webGL uniform location where to store the value
  44895. * @param array defines the array of number to store
  44896. */
  44897. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44898. /**
  44899. * Set the value of an uniform to an array of number (stored as vec2)
  44900. * @param uniform defines the webGL uniform location where to store the value
  44901. * @param array defines the array of number to store
  44902. */
  44903. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44904. /**
  44905. * Set the value of an uniform to an array of number (stored as vec3)
  44906. * @param uniform defines the webGL uniform location where to store the value
  44907. * @param array defines the array of number to store
  44908. */
  44909. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44910. /**
  44911. * Set the value of an uniform to an array of number (stored as vec4)
  44912. * @param uniform defines the webGL uniform location where to store the value
  44913. * @param array defines the array of number to store
  44914. */
  44915. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44916. /**
  44917. * Set the value of an uniform to an array of float32 (stored as matrices)
  44918. * @param uniform defines the webGL uniform location where to store the value
  44919. * @param matrices defines the array of float32 to store
  44920. */
  44921. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44922. /**
  44923. * Set the value of an uniform to a matrix (3x3)
  44924. * @param uniform defines the webGL uniform location where to store the value
  44925. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  44926. */
  44927. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44928. /**
  44929. * Set the value of an uniform to a matrix (2x2)
  44930. * @param uniform defines the webGL uniform location where to store the value
  44931. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  44932. */
  44933. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44934. /**
  44935. * Set the value of an uniform to a number (float)
  44936. * @param uniform defines the webGL uniform location where to store the value
  44937. * @param value defines the float number to store
  44938. */
  44939. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44940. /**
  44941. * Set the value of an uniform to a vec2
  44942. * @param uniform defines the webGL uniform location where to store the value
  44943. * @param x defines the 1st component of the value
  44944. * @param y defines the 2nd component of the value
  44945. */
  44946. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44947. /**
  44948. * Set the value of an uniform to a vec3
  44949. * @param uniform defines the webGL uniform location where to store the value
  44950. * @param x defines the 1st component of the value
  44951. * @param y defines the 2nd component of the value
  44952. * @param z defines the 3rd component of the value
  44953. */
  44954. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44955. /**
  44956. * Set the value of an uniform to a boolean
  44957. * @param uniform defines the webGL uniform location where to store the value
  44958. * @param bool defines the boolean to store
  44959. */
  44960. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44961. /**
  44962. * Set the value of an uniform to a vec4
  44963. * @param uniform defines the webGL uniform location where to store the value
  44964. * @param x defines the 1st component of the value
  44965. * @param y defines the 2nd component of the value
  44966. * @param z defines the 3rd component of the value
  44967. * @param w defines the 4th component of the value
  44968. */
  44969. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44970. /**
  44971. * Sets the current alpha mode
  44972. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  44973. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44974. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44975. */
  44976. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44977. /**
  44978. * Bind webGl buffers directly to the webGL context
  44979. * @param vertexBuffers defines the vertex buffer to bind
  44980. * @param indexBuffer defines the index buffer to bind
  44981. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  44982. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  44983. * @param effect defines the effect associated with the vertex buffer
  44984. */
  44985. bindBuffers(vertexBuffers: {
  44986. [key: string]: VertexBuffer;
  44987. }, indexBuffer: DataBuffer, effect: Effect): void;
  44988. /**
  44989. * Force the entire cache to be cleared
  44990. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  44991. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  44992. */
  44993. wipeCaches(bruteForce?: boolean): void;
  44994. /**
  44995. * Send a draw order
  44996. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  44997. * @param indexStart defines the starting index
  44998. * @param indexCount defines the number of index to draw
  44999. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45000. */
  45001. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45002. /**
  45003. * Draw a list of indexed primitives
  45004. * @param fillMode defines the primitive to use
  45005. * @param indexStart defines the starting index
  45006. * @param indexCount defines the number of index to draw
  45007. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45008. */
  45009. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45010. /**
  45011. * Draw a list of unindexed primitives
  45012. * @param fillMode defines the primitive to use
  45013. * @param verticesStart defines the index of first vertex to draw
  45014. * @param verticesCount defines the count of vertices to draw
  45015. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45016. */
  45017. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45018. /** @hidden */
  45019. _createTexture(): WebGLTexture;
  45020. /** @hidden */
  45021. _releaseTexture(texture: InternalTexture): void;
  45022. /**
  45023. * Usually called from Texture.ts.
  45024. * Passed information to create a WebGLTexture
  45025. * @param urlArg defines a value which contains one of the following:
  45026. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45027. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45028. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45029. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45030. * @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)
  45031. * @param scene needed for loading to the correct scene
  45032. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45033. * @param onLoad optional callback to be called upon successful completion
  45034. * @param onError optional callback to be called upon failure
  45035. * @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
  45036. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45037. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45038. * @param forcedExtension defines the extension to use to pick the right loader
  45039. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45040. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45041. */
  45042. 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;
  45043. /**
  45044. * Creates a new render target texture
  45045. * @param size defines the size of the texture
  45046. * @param options defines the options used to create the texture
  45047. * @returns a new render target texture stored in an InternalTexture
  45048. */
  45049. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45050. /**
  45051. * Update the sampling mode of a given texture
  45052. * @param samplingMode defines the required sampling mode
  45053. * @param texture defines the texture to update
  45054. */
  45055. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45056. /**
  45057. * Binds the frame buffer to the specified texture.
  45058. * @param texture The texture to render to or null for the default canvas
  45059. * @param faceIndex The face of the texture to render to in case of cube texture
  45060. * @param requiredWidth The width of the target to render to
  45061. * @param requiredHeight The height of the target to render to
  45062. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45063. * @param depthStencilTexture The depth stencil texture to use to render
  45064. * @param lodLevel defines le lod level to bind to the frame buffer
  45065. */
  45066. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45067. /**
  45068. * Unbind the current render target texture from the webGL context
  45069. * @param texture defines the render target texture to unbind
  45070. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45071. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45072. */
  45073. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45074. /**
  45075. * Creates a dynamic vertex buffer
  45076. * @param vertices the data for the dynamic vertex buffer
  45077. * @returns the new WebGL dynamic buffer
  45078. */
  45079. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45080. /**
  45081. * Update the content of a dynamic texture
  45082. * @param texture defines the texture to update
  45083. * @param canvas defines the canvas containing the source
  45084. * @param invertY defines if data must be stored with Y axis inverted
  45085. * @param premulAlpha defines if alpha is stored as premultiplied
  45086. * @param format defines the format of the data
  45087. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45088. */
  45089. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45090. /**
  45091. * Gets a boolean indicating if all created effects are ready
  45092. * @returns true if all effects are ready
  45093. */
  45094. areAllEffectsReady(): boolean;
  45095. /**
  45096. * @hidden
  45097. * Get the current error code of the webGL context
  45098. * @returns the error code
  45099. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45100. */
  45101. getError(): number;
  45102. /** @hidden */
  45103. _getUnpackAlignement(): number;
  45104. /** @hidden */
  45105. _unpackFlipY(value: boolean): void;
  45106. /**
  45107. * Update a dynamic index buffer
  45108. * @param indexBuffer defines the target index buffer
  45109. * @param indices defines the data to update
  45110. * @param offset defines the offset in the target index buffer where update should start
  45111. */
  45112. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45113. /**
  45114. * Updates a dynamic vertex buffer.
  45115. * @param vertexBuffer the vertex buffer to update
  45116. * @param vertices the data used to update the vertex buffer
  45117. * @param byteOffset the byte offset of the data (optional)
  45118. * @param byteLength the byte length of the data (optional)
  45119. */
  45120. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45121. /** @hidden */
  45122. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45123. /** @hidden */
  45124. _bindTexture(channel: number, texture: InternalTexture): void;
  45125. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45126. /**
  45127. * 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
  45128. */
  45129. releaseEffects(): void;
  45130. displayLoadingUI(): void;
  45131. hideLoadingUI(): void;
  45132. /** @hidden */
  45133. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45134. /** @hidden */
  45135. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45136. /** @hidden */
  45137. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45138. /** @hidden */
  45139. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45140. }
  45141. }
  45142. declare module BABYLON {
  45143. /** @hidden */
  45144. export class _OcclusionDataStorage {
  45145. /** @hidden */
  45146. occlusionInternalRetryCounter: number;
  45147. /** @hidden */
  45148. isOcclusionQueryInProgress: boolean;
  45149. /** @hidden */
  45150. isOccluded: boolean;
  45151. /** @hidden */
  45152. occlusionRetryCount: number;
  45153. /** @hidden */
  45154. occlusionType: number;
  45155. /** @hidden */
  45156. occlusionQueryAlgorithmType: number;
  45157. }
  45158. interface Engine {
  45159. /**
  45160. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45161. * @return the new query
  45162. */
  45163. createQuery(): WebGLQuery;
  45164. /**
  45165. * Delete and release a webGL query
  45166. * @param query defines the query to delete
  45167. * @return the current engine
  45168. */
  45169. deleteQuery(query: WebGLQuery): Engine;
  45170. /**
  45171. * Check if a given query has resolved and got its value
  45172. * @param query defines the query to check
  45173. * @returns true if the query got its value
  45174. */
  45175. isQueryResultAvailable(query: WebGLQuery): boolean;
  45176. /**
  45177. * Gets the value of a given query
  45178. * @param query defines the query to check
  45179. * @returns the value of the query
  45180. */
  45181. getQueryResult(query: WebGLQuery): number;
  45182. /**
  45183. * Initiates an occlusion query
  45184. * @param algorithmType defines the algorithm to use
  45185. * @param query defines the query to use
  45186. * @returns the current engine
  45187. * @see http://doc.babylonjs.com/features/occlusionquery
  45188. */
  45189. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45190. /**
  45191. * Ends an occlusion query
  45192. * @see http://doc.babylonjs.com/features/occlusionquery
  45193. * @param algorithmType defines the algorithm to use
  45194. * @returns the current engine
  45195. */
  45196. endOcclusionQuery(algorithmType: number): Engine;
  45197. /**
  45198. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45199. * Please note that only one query can be issued at a time
  45200. * @returns a time token used to track the time span
  45201. */
  45202. startTimeQuery(): Nullable<_TimeToken>;
  45203. /**
  45204. * Ends a time query
  45205. * @param token defines the token used to measure the time span
  45206. * @returns the time spent (in ns)
  45207. */
  45208. endTimeQuery(token: _TimeToken): int;
  45209. /** @hidden */
  45210. _currentNonTimestampToken: Nullable<_TimeToken>;
  45211. /** @hidden */
  45212. _createTimeQuery(): WebGLQuery;
  45213. /** @hidden */
  45214. _deleteTimeQuery(query: WebGLQuery): void;
  45215. /** @hidden */
  45216. _getGlAlgorithmType(algorithmType: number): number;
  45217. /** @hidden */
  45218. _getTimeQueryResult(query: WebGLQuery): any;
  45219. /** @hidden */
  45220. _getTimeQueryAvailability(query: WebGLQuery): any;
  45221. }
  45222. interface AbstractMesh {
  45223. /**
  45224. * Backing filed
  45225. * @hidden
  45226. */
  45227. __occlusionDataStorage: _OcclusionDataStorage;
  45228. /**
  45229. * Access property
  45230. * @hidden
  45231. */
  45232. _occlusionDataStorage: _OcclusionDataStorage;
  45233. /**
  45234. * 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.
  45235. * The default value is -1 which means don't break the query and wait till the result
  45236. * @see http://doc.babylonjs.com/features/occlusionquery
  45237. */
  45238. occlusionRetryCount: number;
  45239. /**
  45240. * 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:
  45241. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45242. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45243. * * 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.
  45244. * @see http://doc.babylonjs.com/features/occlusionquery
  45245. */
  45246. occlusionType: number;
  45247. /**
  45248. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45249. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45250. * * 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.
  45251. * @see http://doc.babylonjs.com/features/occlusionquery
  45252. */
  45253. occlusionQueryAlgorithmType: number;
  45254. /**
  45255. * 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
  45256. * @see http://doc.babylonjs.com/features/occlusionquery
  45257. */
  45258. isOccluded: boolean;
  45259. /**
  45260. * Flag to check the progress status of the query
  45261. * @see http://doc.babylonjs.com/features/occlusionquery
  45262. */
  45263. isOcclusionQueryInProgress: boolean;
  45264. }
  45265. }
  45266. declare module BABYLON {
  45267. /** @hidden */
  45268. export var _forceTransformFeedbackToBundle: boolean;
  45269. interface Engine {
  45270. /**
  45271. * Creates a webGL transform feedback object
  45272. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45273. * @returns the webGL transform feedback object
  45274. */
  45275. createTransformFeedback(): WebGLTransformFeedback;
  45276. /**
  45277. * Delete a webGL transform feedback object
  45278. * @param value defines the webGL transform feedback object to delete
  45279. */
  45280. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45281. /**
  45282. * Bind a webGL transform feedback object to the webgl context
  45283. * @param value defines the webGL transform feedback object to bind
  45284. */
  45285. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45286. /**
  45287. * Begins a transform feedback operation
  45288. * @param usePoints defines if points or triangles must be used
  45289. */
  45290. beginTransformFeedback(usePoints: boolean): void;
  45291. /**
  45292. * Ends a transform feedback operation
  45293. */
  45294. endTransformFeedback(): void;
  45295. /**
  45296. * Specify the varyings to use with transform feedback
  45297. * @param program defines the associated webGL program
  45298. * @param value defines the list of strings representing the varying names
  45299. */
  45300. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45301. /**
  45302. * Bind a webGL buffer for a transform feedback operation
  45303. * @param value defines the webGL buffer to bind
  45304. */
  45305. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45306. }
  45307. }
  45308. declare module BABYLON {
  45309. /**
  45310. * Creation options of the multi render target texture.
  45311. */
  45312. export interface IMultiRenderTargetOptions {
  45313. /**
  45314. * Define if the texture needs to create mip maps after render.
  45315. */
  45316. generateMipMaps?: boolean;
  45317. /**
  45318. * Define the types of all the draw buffers we want to create
  45319. */
  45320. types?: number[];
  45321. /**
  45322. * Define the sampling modes of all the draw buffers we want to create
  45323. */
  45324. samplingModes?: number[];
  45325. /**
  45326. * Define if a depth buffer is required
  45327. */
  45328. generateDepthBuffer?: boolean;
  45329. /**
  45330. * Define if a stencil buffer is required
  45331. */
  45332. generateStencilBuffer?: boolean;
  45333. /**
  45334. * Define if a depth texture is required instead of a depth buffer
  45335. */
  45336. generateDepthTexture?: boolean;
  45337. /**
  45338. * Define the number of desired draw buffers
  45339. */
  45340. textureCount?: number;
  45341. /**
  45342. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45343. */
  45344. doNotChangeAspectRatio?: boolean;
  45345. /**
  45346. * Define the default type of the buffers we are creating
  45347. */
  45348. defaultType?: number;
  45349. }
  45350. /**
  45351. * A multi render target, like a render target provides the ability to render to a texture.
  45352. * Unlike the render target, it can render to several draw buffers in one draw.
  45353. * This is specially interesting in deferred rendering or for any effects requiring more than
  45354. * just one color from a single pass.
  45355. */
  45356. export class MultiRenderTarget extends RenderTargetTexture {
  45357. private _internalTextures;
  45358. private _textures;
  45359. private _multiRenderTargetOptions;
  45360. /**
  45361. * Get if draw buffers are currently supported by the used hardware and browser.
  45362. */
  45363. readonly isSupported: boolean;
  45364. /**
  45365. * Get the list of textures generated by the multi render target.
  45366. */
  45367. readonly textures: Texture[];
  45368. /**
  45369. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45370. */
  45371. readonly depthTexture: Texture;
  45372. /**
  45373. * Set the wrapping mode on U of all the textures we are rendering to.
  45374. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45375. */
  45376. wrapU: number;
  45377. /**
  45378. * Set the wrapping mode on V of all the textures we are rendering to.
  45379. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45380. */
  45381. wrapV: number;
  45382. /**
  45383. * Instantiate a new multi render target texture.
  45384. * A multi render target, like a render target provides the ability to render to a texture.
  45385. * Unlike the render target, it can render to several draw buffers in one draw.
  45386. * This is specially interesting in deferred rendering or for any effects requiring more than
  45387. * just one color from a single pass.
  45388. * @param name Define the name of the texture
  45389. * @param size Define the size of the buffers to render to
  45390. * @param count Define the number of target we are rendering into
  45391. * @param scene Define the scene the texture belongs to
  45392. * @param options Define the options used to create the multi render target
  45393. */
  45394. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45395. /** @hidden */
  45396. _rebuild(): void;
  45397. private _createInternalTextures;
  45398. private _createTextures;
  45399. /**
  45400. * Define the number of samples used if MSAA is enabled.
  45401. */
  45402. samples: number;
  45403. /**
  45404. * Resize all the textures in the multi render target.
  45405. * Be carrefull as it will recreate all the data in the new texture.
  45406. * @param size Define the new size
  45407. */
  45408. resize(size: any): void;
  45409. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45410. /**
  45411. * Dispose the render targets and their associated resources
  45412. */
  45413. dispose(): void;
  45414. /**
  45415. * Release all the underlying texture used as draw buffers.
  45416. */
  45417. releaseInternalTextures(): void;
  45418. }
  45419. }
  45420. declare module BABYLON {
  45421. interface ThinEngine {
  45422. /**
  45423. * Unbind a list of render target textures from the webGL context
  45424. * This is used only when drawBuffer extension or webGL2 are active
  45425. * @param textures defines the render target textures to unbind
  45426. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45427. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45428. */
  45429. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45430. /**
  45431. * Create a multi render target texture
  45432. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45433. * @param size defines the size of the texture
  45434. * @param options defines the creation options
  45435. * @returns the cube texture as an InternalTexture
  45436. */
  45437. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45438. /**
  45439. * Update the sample count for a given multiple render target texture
  45440. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45441. * @param textures defines the textures to update
  45442. * @param samples defines the sample count to set
  45443. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45444. */
  45445. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45446. }
  45447. }
  45448. declare module BABYLON {
  45449. /**
  45450. * Class used to define an additional view for the engine
  45451. * @see https://doc.babylonjs.com/how_to/multi_canvases
  45452. */
  45453. export class EngineView {
  45454. /** Defines the canvas where to render the view */
  45455. target: HTMLCanvasElement;
  45456. /** Defines an optional camera used to render the view (will use active camera else) */
  45457. camera?: Camera;
  45458. }
  45459. interface Engine {
  45460. /**
  45461. * Gets or sets the HTML element to use for attaching events
  45462. */
  45463. inputElement: Nullable<HTMLElement>;
  45464. /**
  45465. * Gets the current engine view
  45466. * @see https://doc.babylonjs.com/how_to/multi_canvases
  45467. */
  45468. activeView: Nullable<EngineView>;
  45469. /** Gets or sets the list of views */
  45470. views: EngineView[];
  45471. /**
  45472. * Register a new child canvas
  45473. * @param canvas defines the canvas to register
  45474. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  45475. * @returns the associated view
  45476. */
  45477. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  45478. /**
  45479. * Remove a registered child canvas
  45480. * @param canvas defines the canvas to remove
  45481. * @returns the current engine
  45482. */
  45483. unRegisterView(canvas: HTMLCanvasElement): Engine;
  45484. }
  45485. }
  45486. declare module BABYLON {
  45487. /**
  45488. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  45489. */
  45490. export interface CubeMapInfo {
  45491. /**
  45492. * The pixel array for the front face.
  45493. * This is stored in format, left to right, up to down format.
  45494. */
  45495. front: Nullable<ArrayBufferView>;
  45496. /**
  45497. * The pixel array for the back face.
  45498. * This is stored in format, left to right, up to down format.
  45499. */
  45500. back: Nullable<ArrayBufferView>;
  45501. /**
  45502. * The pixel array for the left face.
  45503. * This is stored in format, left to right, up to down format.
  45504. */
  45505. left: Nullable<ArrayBufferView>;
  45506. /**
  45507. * The pixel array for the right face.
  45508. * This is stored in format, left to right, up to down format.
  45509. */
  45510. right: Nullable<ArrayBufferView>;
  45511. /**
  45512. * The pixel array for the up face.
  45513. * This is stored in format, left to right, up to down format.
  45514. */
  45515. up: Nullable<ArrayBufferView>;
  45516. /**
  45517. * The pixel array for the down face.
  45518. * This is stored in format, left to right, up to down format.
  45519. */
  45520. down: Nullable<ArrayBufferView>;
  45521. /**
  45522. * The size of the cubemap stored.
  45523. *
  45524. * Each faces will be size * size pixels.
  45525. */
  45526. size: number;
  45527. /**
  45528. * The format of the texture.
  45529. *
  45530. * RGBA, RGB.
  45531. */
  45532. format: number;
  45533. /**
  45534. * The type of the texture data.
  45535. *
  45536. * UNSIGNED_INT, FLOAT.
  45537. */
  45538. type: number;
  45539. /**
  45540. * Specifies whether the texture is in gamma space.
  45541. */
  45542. gammaSpace: boolean;
  45543. }
  45544. /**
  45545. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  45546. */
  45547. export class PanoramaToCubeMapTools {
  45548. private static FACE_FRONT;
  45549. private static FACE_BACK;
  45550. private static FACE_RIGHT;
  45551. private static FACE_LEFT;
  45552. private static FACE_DOWN;
  45553. private static FACE_UP;
  45554. /**
  45555. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  45556. *
  45557. * @param float32Array The source data.
  45558. * @param inputWidth The width of the input panorama.
  45559. * @param inputHeight The height of the input panorama.
  45560. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  45561. * @return The cubemap data
  45562. */
  45563. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  45564. private static CreateCubemapTexture;
  45565. private static CalcProjectionSpherical;
  45566. }
  45567. }
  45568. declare module BABYLON {
  45569. /**
  45570. * Helper class dealing with the extraction of spherical polynomial dataArray
  45571. * from a cube map.
  45572. */
  45573. export class CubeMapToSphericalPolynomialTools {
  45574. private static FileFaces;
  45575. /**
  45576. * Converts a texture to the according Spherical Polynomial data.
  45577. * This extracts the first 3 orders only as they are the only one used in the lighting.
  45578. *
  45579. * @param texture The texture to extract the information from.
  45580. * @return The Spherical Polynomial data.
  45581. */
  45582. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  45583. /**
  45584. * Converts a cubemap to the according Spherical Polynomial data.
  45585. * This extracts the first 3 orders only as they are the only one used in the lighting.
  45586. *
  45587. * @param cubeInfo The Cube map to extract the information from.
  45588. * @return The Spherical Polynomial data.
  45589. */
  45590. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  45591. }
  45592. }
  45593. declare module BABYLON {
  45594. interface BaseTexture {
  45595. /**
  45596. * Get the polynomial representation of the texture data.
  45597. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  45598. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  45599. */
  45600. sphericalPolynomial: Nullable<SphericalPolynomial>;
  45601. }
  45602. }
  45603. declare module BABYLON {
  45604. /** @hidden */
  45605. export var rgbdEncodePixelShader: {
  45606. name: string;
  45607. shader: string;
  45608. };
  45609. }
  45610. declare module BABYLON {
  45611. /** @hidden */
  45612. export var rgbdDecodePixelShader: {
  45613. name: string;
  45614. shader: string;
  45615. };
  45616. }
  45617. declare module BABYLON {
  45618. /**
  45619. * Raw texture data and descriptor sufficient for WebGL texture upload
  45620. */
  45621. export interface EnvironmentTextureInfo {
  45622. /**
  45623. * Version of the environment map
  45624. */
  45625. version: number;
  45626. /**
  45627. * Width of image
  45628. */
  45629. width: number;
  45630. /**
  45631. * Irradiance information stored in the file.
  45632. */
  45633. irradiance: any;
  45634. /**
  45635. * Specular information stored in the file.
  45636. */
  45637. specular: any;
  45638. }
  45639. /**
  45640. * Defines One Image in the file. It requires only the position in the file
  45641. * as well as the length.
  45642. */
  45643. interface BufferImageData {
  45644. /**
  45645. * Length of the image data.
  45646. */
  45647. length: number;
  45648. /**
  45649. * Position of the data from the null terminator delimiting the end of the JSON.
  45650. */
  45651. position: number;
  45652. }
  45653. /**
  45654. * Defines the specular data enclosed in the file.
  45655. * This corresponds to the version 1 of the data.
  45656. */
  45657. export interface EnvironmentTextureSpecularInfoV1 {
  45658. /**
  45659. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  45660. */
  45661. specularDataPosition?: number;
  45662. /**
  45663. * This contains all the images data needed to reconstruct the cubemap.
  45664. */
  45665. mipmaps: Array<BufferImageData>;
  45666. /**
  45667. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  45668. */
  45669. lodGenerationScale: number;
  45670. }
  45671. /**
  45672. * Sets of helpers addressing the serialization and deserialization of environment texture
  45673. * stored in a BabylonJS env file.
  45674. * Those files are usually stored as .env files.
  45675. */
  45676. export class EnvironmentTextureTools {
  45677. /**
  45678. * Magic number identifying the env file.
  45679. */
  45680. private static _MagicBytes;
  45681. /**
  45682. * Gets the environment info from an env file.
  45683. * @param data The array buffer containing the .env bytes.
  45684. * @returns the environment file info (the json header) if successfully parsed.
  45685. */
  45686. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45687. /**
  45688. * Creates an environment texture from a loaded cube texture.
  45689. * @param texture defines the cube texture to convert in env file
  45690. * @return a promise containing the environment data if succesfull.
  45691. */
  45692. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45693. /**
  45694. * Creates a JSON representation of the spherical data.
  45695. * @param texture defines the texture containing the polynomials
  45696. * @return the JSON representation of the spherical info
  45697. */
  45698. private static _CreateEnvTextureIrradiance;
  45699. /**
  45700. * Creates the ArrayBufferViews used for initializing environment texture image data.
  45701. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  45702. * @param info parameters that determine what views will be created for accessing the underlying buffer
  45703. * @return the views described by info providing access to the underlying buffer
  45704. */
  45705. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  45706. /**
  45707. * Uploads the texture info contained in the env file to the GPU.
  45708. * @param texture defines the internal texture to upload to
  45709. * @param arrayBuffer defines the buffer cotaining the data to load
  45710. * @param info defines the texture info retrieved through the GetEnvInfo method
  45711. * @returns a promise
  45712. */
  45713. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45714. private static _OnImageReadyAsync;
  45715. /**
  45716. * Uploads the levels of image data to the GPU.
  45717. * @param texture defines the internal texture to upload to
  45718. * @param imageData defines the array buffer views of image data [mipmap][face]
  45719. * @returns a promise
  45720. */
  45721. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45722. /**
  45723. * Uploads spherical polynomials information to the texture.
  45724. * @param texture defines the texture we are trying to upload the information to
  45725. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45726. */
  45727. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45728. /** @hidden */
  45729. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45730. }
  45731. }
  45732. declare module BABYLON {
  45733. /**
  45734. * Contains position and normal vectors for a vertex
  45735. */
  45736. export class PositionNormalVertex {
  45737. /** the position of the vertex (defaut: 0,0,0) */
  45738. position: Vector3;
  45739. /** the normal of the vertex (defaut: 0,1,0) */
  45740. normal: Vector3;
  45741. /**
  45742. * Creates a PositionNormalVertex
  45743. * @param position the position of the vertex (defaut: 0,0,0)
  45744. * @param normal the normal of the vertex (defaut: 0,1,0)
  45745. */
  45746. constructor(
  45747. /** the position of the vertex (defaut: 0,0,0) */
  45748. position?: Vector3,
  45749. /** the normal of the vertex (defaut: 0,1,0) */
  45750. normal?: Vector3);
  45751. /**
  45752. * Clones the PositionNormalVertex
  45753. * @returns the cloned PositionNormalVertex
  45754. */
  45755. clone(): PositionNormalVertex;
  45756. }
  45757. /**
  45758. * Contains position, normal and uv vectors for a vertex
  45759. */
  45760. export class PositionNormalTextureVertex {
  45761. /** the position of the vertex (defaut: 0,0,0) */
  45762. position: Vector3;
  45763. /** the normal of the vertex (defaut: 0,1,0) */
  45764. normal: Vector3;
  45765. /** the uv of the vertex (default: 0,0) */
  45766. uv: Vector2;
  45767. /**
  45768. * Creates a PositionNormalTextureVertex
  45769. * @param position the position of the vertex (defaut: 0,0,0)
  45770. * @param normal the normal of the vertex (defaut: 0,1,0)
  45771. * @param uv the uv of the vertex (default: 0,0)
  45772. */
  45773. constructor(
  45774. /** the position of the vertex (defaut: 0,0,0) */
  45775. position?: Vector3,
  45776. /** the normal of the vertex (defaut: 0,1,0) */
  45777. normal?: Vector3,
  45778. /** the uv of the vertex (default: 0,0) */
  45779. uv?: Vector2);
  45780. /**
  45781. * Clones the PositionNormalTextureVertex
  45782. * @returns the cloned PositionNormalTextureVertex
  45783. */
  45784. clone(): PositionNormalTextureVertex;
  45785. }
  45786. }
  45787. declare module BABYLON {
  45788. /** @hidden */
  45789. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  45790. private _genericAttributeLocation;
  45791. private _varyingLocationCount;
  45792. private _varyingLocationMap;
  45793. private _replacements;
  45794. private _textureCount;
  45795. private _uniforms;
  45796. lineProcessor(line: string): string;
  45797. attributeProcessor(attribute: string): string;
  45798. varyingProcessor(varying: string, isFragment: boolean): string;
  45799. uniformProcessor(uniform: string): string;
  45800. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  45801. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  45802. }
  45803. }
  45804. declare module BABYLON {
  45805. /**
  45806. * Container for accessors for natively-stored mesh data buffers.
  45807. */
  45808. class NativeDataBuffer extends DataBuffer {
  45809. /**
  45810. * Accessor value used to identify/retrieve a natively-stored index buffer.
  45811. */
  45812. nativeIndexBuffer?: any;
  45813. /**
  45814. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  45815. */
  45816. nativeVertexBuffer?: any;
  45817. }
  45818. /** @hidden */
  45819. class NativeTexture extends InternalTexture {
  45820. getInternalTexture(): InternalTexture;
  45821. getViewCount(): number;
  45822. }
  45823. /** @hidden */
  45824. export class NativeEngine extends Engine {
  45825. private readonly _native;
  45826. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  45827. private readonly INVALID_HANDLE;
  45828. getHardwareScalingLevel(): number;
  45829. constructor();
  45830. /**
  45831. * Can be used to override the current requestAnimationFrame requester.
  45832. * @hidden
  45833. */
  45834. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  45835. /**
  45836. * Override default engine behavior.
  45837. * @param color
  45838. * @param backBuffer
  45839. * @param depth
  45840. * @param stencil
  45841. */
  45842. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  45843. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45844. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  45845. createVertexBuffer(data: DataArray): NativeDataBuffer;
  45846. recordVertexArrayObject(vertexBuffers: {
  45847. [key: string]: VertexBuffer;
  45848. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  45849. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45850. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45851. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45852. /**
  45853. * Draw a list of indexed primitives
  45854. * @param fillMode defines the primitive to use
  45855. * @param indexStart defines the starting index
  45856. * @param indexCount defines the number of index to draw
  45857. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45858. */
  45859. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45860. /**
  45861. * Draw a list of unindexed primitives
  45862. * @param fillMode defines the primitive to use
  45863. * @param verticesStart defines the index of first vertex to draw
  45864. * @param verticesCount defines the count of vertices to draw
  45865. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45866. */
  45867. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45868. createPipelineContext(): IPipelineContext;
  45869. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  45870. /** @hidden */
  45871. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45872. /** @hidden */
  45873. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45874. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45875. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45876. protected _setProgram(program: WebGLProgram): void;
  45877. _releaseEffect(effect: Effect): void;
  45878. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45879. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  45880. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45881. bindSamplers(effect: Effect): void;
  45882. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  45883. getRenderWidth(useScreen?: boolean): number;
  45884. getRenderHeight(useScreen?: boolean): number;
  45885. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  45886. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45887. /**
  45888. * Set the z offset to apply to current rendering
  45889. * @param value defines the offset to apply
  45890. */
  45891. setZOffset(value: number): void;
  45892. /**
  45893. * Gets the current value of the zOffset
  45894. * @returns the current zOffset state
  45895. */
  45896. getZOffset(): number;
  45897. /**
  45898. * Enable or disable depth buffering
  45899. * @param enable defines the state to set
  45900. */
  45901. setDepthBuffer(enable: boolean): void;
  45902. /**
  45903. * Gets a boolean indicating if depth writing is enabled
  45904. * @returns the current depth writing state
  45905. */
  45906. getDepthWrite(): boolean;
  45907. /**
  45908. * Enable or disable depth writing
  45909. * @param enable defines the state to set
  45910. */
  45911. setDepthWrite(enable: boolean): void;
  45912. /**
  45913. * Enable or disable color writing
  45914. * @param enable defines the state to set
  45915. */
  45916. setColorWrite(enable: boolean): void;
  45917. /**
  45918. * Gets a boolean indicating if color writing is enabled
  45919. * @returns the current color writing state
  45920. */
  45921. getColorWrite(): boolean;
  45922. /**
  45923. * Sets alpha constants used by some alpha blending modes
  45924. * @param r defines the red component
  45925. * @param g defines the green component
  45926. * @param b defines the blue component
  45927. * @param a defines the alpha component
  45928. */
  45929. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  45930. /**
  45931. * Sets the current alpha mode
  45932. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  45933. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45934. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45935. */
  45936. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45937. /**
  45938. * Gets the current alpha mode
  45939. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45940. * @returns the current alpha mode
  45941. */
  45942. getAlphaMode(): number;
  45943. setInt(uniform: WebGLUniformLocation, int: number): void;
  45944. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45945. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45946. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45947. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45948. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45949. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45950. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45951. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45952. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45953. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45954. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45955. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45956. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45957. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45958. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45959. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45960. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45961. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45962. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45963. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  45964. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  45965. wipeCaches(bruteForce?: boolean): void;
  45966. _createTexture(): WebGLTexture;
  45967. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  45968. /**
  45969. * Usually called from BABYLON.Texture.ts.
  45970. * Passed information to create a WebGLTexture
  45971. * @param urlArg defines a value which contains one of the following:
  45972. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45973. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45974. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45975. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45976. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  45977. * @param scene needed for loading to the correct scene
  45978. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  45979. * @param onLoad optional callback to be called upon successful completion
  45980. * @param onError optional callback to be called upon failure
  45981. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  45982. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45983. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45984. * @param forcedExtension defines the extension to use to pick the right loader
  45985. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45986. */
  45987. 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;
  45988. /**
  45989. * Creates a cube texture
  45990. * @param rootUrl defines the url where the files to load is located
  45991. * @param scene defines the current scene
  45992. * @param files defines the list of files to load (1 per face)
  45993. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45994. * @param onLoad defines an optional callback raised when the texture is loaded
  45995. * @param onError defines an optional callback raised if there is an issue to load the texture
  45996. * @param format defines the format of the data
  45997. * @param forcedExtension defines the extension to use to pick the right loader
  45998. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45999. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46000. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46001. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46002. * @returns the cube texture as an InternalTexture
  46003. */
  46004. 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;
  46005. private _getSamplingFilter;
  46006. private static _GetNativeTextureFormat;
  46007. createRenderTargetTexture(size: number | {
  46008. width: number;
  46009. height: number;
  46010. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  46011. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46012. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46013. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46014. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46015. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46016. /**
  46017. * Updates a dynamic vertex buffer.
  46018. * @param vertexBuffer the vertex buffer to update
  46019. * @param data the data used to update the vertex buffer
  46020. * @param byteOffset the byte offset of the data (optional)
  46021. * @param byteLength the byte length of the data (optional)
  46022. */
  46023. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46024. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46025. private _updateAnisotropicLevel;
  46026. private _getAddressMode;
  46027. /** @hidden */
  46028. _bindTexture(channel: number, texture: InternalTexture): void;
  46029. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46030. releaseEffects(): void;
  46031. /** @hidden */
  46032. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46033. /** @hidden */
  46034. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46035. /** @hidden */
  46036. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46037. /** @hidden */
  46038. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46039. }
  46040. }
  46041. declare module BABYLON {
  46042. /**
  46043. * Gather the list of clipboard event types as constants.
  46044. */
  46045. export class ClipboardEventTypes {
  46046. /**
  46047. * The clipboard event is fired when a copy command is active (pressed).
  46048. */
  46049. static readonly COPY: number;
  46050. /**
  46051. * The clipboard event is fired when a cut command is active (pressed).
  46052. */
  46053. static readonly CUT: number;
  46054. /**
  46055. * The clipboard event is fired when a paste command is active (pressed).
  46056. */
  46057. static readonly PASTE: number;
  46058. }
  46059. /**
  46060. * This class is used to store clipboard related info for the onClipboardObservable event.
  46061. */
  46062. export class ClipboardInfo {
  46063. /**
  46064. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46065. */
  46066. type: number;
  46067. /**
  46068. * Defines the related dom event
  46069. */
  46070. event: ClipboardEvent;
  46071. /**
  46072. *Creates an instance of ClipboardInfo.
  46073. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46074. * @param event Defines the related dom event
  46075. */
  46076. constructor(
  46077. /**
  46078. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46079. */
  46080. type: number,
  46081. /**
  46082. * Defines the related dom event
  46083. */
  46084. event: ClipboardEvent);
  46085. /**
  46086. * Get the clipboard event's type from the keycode.
  46087. * @param keyCode Defines the keyCode for the current keyboard event.
  46088. * @return {number}
  46089. */
  46090. static GetTypeFromCharacter(keyCode: number): number;
  46091. }
  46092. }
  46093. declare module BABYLON {
  46094. /**
  46095. * Google Daydream controller
  46096. */
  46097. export class DaydreamController extends WebVRController {
  46098. /**
  46099. * Base Url for the controller model.
  46100. */
  46101. static MODEL_BASE_URL: string;
  46102. /**
  46103. * File name for the controller model.
  46104. */
  46105. static MODEL_FILENAME: string;
  46106. /**
  46107. * Gamepad Id prefix used to identify Daydream Controller.
  46108. */
  46109. static readonly GAMEPAD_ID_PREFIX: string;
  46110. /**
  46111. * Creates a new DaydreamController from a gamepad
  46112. * @param vrGamepad the gamepad that the controller should be created from
  46113. */
  46114. constructor(vrGamepad: any);
  46115. /**
  46116. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46117. * @param scene scene in which to add meshes
  46118. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46119. */
  46120. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46121. /**
  46122. * Called once for each button that changed state since the last frame
  46123. * @param buttonIdx Which button index changed
  46124. * @param state New state of the button
  46125. * @param changes Which properties on the state changed since last frame
  46126. */
  46127. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46128. }
  46129. }
  46130. declare module BABYLON {
  46131. /**
  46132. * Gear VR Controller
  46133. */
  46134. export class GearVRController extends WebVRController {
  46135. /**
  46136. * Base Url for the controller model.
  46137. */
  46138. static MODEL_BASE_URL: string;
  46139. /**
  46140. * File name for the controller model.
  46141. */
  46142. static MODEL_FILENAME: string;
  46143. /**
  46144. * Gamepad Id prefix used to identify this controller.
  46145. */
  46146. static readonly GAMEPAD_ID_PREFIX: string;
  46147. private readonly _buttonIndexToObservableNameMap;
  46148. /**
  46149. * Creates a new GearVRController from a gamepad
  46150. * @param vrGamepad the gamepad that the controller should be created from
  46151. */
  46152. constructor(vrGamepad: any);
  46153. /**
  46154. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46155. * @param scene scene in which to add meshes
  46156. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46157. */
  46158. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46159. /**
  46160. * Called once for each button that changed state since the last frame
  46161. * @param buttonIdx Which button index changed
  46162. * @param state New state of the button
  46163. * @param changes Which properties on the state changed since last frame
  46164. */
  46165. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46166. }
  46167. }
  46168. declare module BABYLON {
  46169. /**
  46170. * Class containing static functions to help procedurally build meshes
  46171. */
  46172. export class PolyhedronBuilder {
  46173. /**
  46174. * Creates a polyhedron mesh
  46175. * * 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
  46176. * * The parameter `size` (positive float, default 1) sets the polygon size
  46177. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46178. * * 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`
  46179. * * 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
  46180. * * 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)`)
  46181. * * 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
  46182. * * 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
  46183. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46184. * * 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
  46185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46186. * @param name defines the name of the mesh
  46187. * @param options defines the options used to create the mesh
  46188. * @param scene defines the hosting scene
  46189. * @returns the polyhedron mesh
  46190. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46191. */
  46192. static CreatePolyhedron(name: string, options: {
  46193. type?: number;
  46194. size?: number;
  46195. sizeX?: number;
  46196. sizeY?: number;
  46197. sizeZ?: number;
  46198. custom?: any;
  46199. faceUV?: Vector4[];
  46200. faceColors?: Color4[];
  46201. flat?: boolean;
  46202. updatable?: boolean;
  46203. sideOrientation?: number;
  46204. frontUVs?: Vector4;
  46205. backUVs?: Vector4;
  46206. }, scene?: Nullable<Scene>): Mesh;
  46207. }
  46208. }
  46209. declare module BABYLON {
  46210. /**
  46211. * Gizmo that enables scaling a mesh along 3 axis
  46212. */
  46213. export class ScaleGizmo extends Gizmo {
  46214. /**
  46215. * Internal gizmo used for interactions on the x axis
  46216. */
  46217. xGizmo: AxisScaleGizmo;
  46218. /**
  46219. * Internal gizmo used for interactions on the y axis
  46220. */
  46221. yGizmo: AxisScaleGizmo;
  46222. /**
  46223. * Internal gizmo used for interactions on the z axis
  46224. */
  46225. zGizmo: AxisScaleGizmo;
  46226. /**
  46227. * Internal gizmo used to scale all axis equally
  46228. */
  46229. uniformScaleGizmo: AxisScaleGizmo;
  46230. private _meshAttached;
  46231. private _updateGizmoRotationToMatchAttachedMesh;
  46232. private _snapDistance;
  46233. private _scaleRatio;
  46234. private _uniformScalingMesh;
  46235. private _octahedron;
  46236. private _sensitivity;
  46237. /** Fires an event when any of it's sub gizmos are dragged */
  46238. onDragStartObservable: Observable<unknown>;
  46239. /** Fires an event when any of it's sub gizmos are released from dragging */
  46240. onDragEndObservable: Observable<unknown>;
  46241. attachedMesh: Nullable<AbstractMesh>;
  46242. /**
  46243. * Creates a ScaleGizmo
  46244. * @param gizmoLayer The utility layer the gizmo will be added to
  46245. */
  46246. constructor(gizmoLayer?: UtilityLayerRenderer);
  46247. updateGizmoRotationToMatchAttachedMesh: boolean;
  46248. /**
  46249. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46250. */
  46251. snapDistance: number;
  46252. /**
  46253. * Ratio for the scale of the gizmo (Default: 1)
  46254. */
  46255. scaleRatio: number;
  46256. /**
  46257. * Sensitivity factor for dragging (Default: 1)
  46258. */
  46259. sensitivity: number;
  46260. /**
  46261. * Disposes of the gizmo
  46262. */
  46263. dispose(): void;
  46264. }
  46265. }
  46266. declare module BABYLON {
  46267. /**
  46268. * Single axis scale gizmo
  46269. */
  46270. export class AxisScaleGizmo extends Gizmo {
  46271. /**
  46272. * Drag behavior responsible for the gizmos dragging interactions
  46273. */
  46274. dragBehavior: PointerDragBehavior;
  46275. private _pointerObserver;
  46276. /**
  46277. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46278. */
  46279. snapDistance: number;
  46280. /**
  46281. * Event that fires each time the gizmo snaps to a new location.
  46282. * * snapDistance is the the change in distance
  46283. */
  46284. onSnapObservable: Observable<{
  46285. snapDistance: number;
  46286. }>;
  46287. /**
  46288. * If the scaling operation should be done on all axis (default: false)
  46289. */
  46290. uniformScaling: boolean;
  46291. /**
  46292. * Custom sensitivity value for the drag strength
  46293. */
  46294. sensitivity: number;
  46295. private _isEnabled;
  46296. private _parent;
  46297. private _arrow;
  46298. private _coloredMaterial;
  46299. private _hoverMaterial;
  46300. /**
  46301. * Creates an AxisScaleGizmo
  46302. * @param gizmoLayer The utility layer the gizmo will be added to
  46303. * @param dragAxis The axis which the gizmo will be able to scale on
  46304. * @param color The color of the gizmo
  46305. */
  46306. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46307. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46308. /**
  46309. * If the gizmo is enabled
  46310. */
  46311. isEnabled: boolean;
  46312. /**
  46313. * Disposes of the gizmo
  46314. */
  46315. dispose(): void;
  46316. /**
  46317. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46318. * @param mesh The mesh to replace the default mesh of the gizmo
  46319. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46320. */
  46321. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46322. }
  46323. }
  46324. declare module BABYLON {
  46325. /**
  46326. * Bounding box gizmo
  46327. */
  46328. export class BoundingBoxGizmo extends Gizmo {
  46329. private _lineBoundingBox;
  46330. private _rotateSpheresParent;
  46331. private _scaleBoxesParent;
  46332. private _boundingDimensions;
  46333. private _renderObserver;
  46334. private _pointerObserver;
  46335. private _scaleDragSpeed;
  46336. private _tmpQuaternion;
  46337. private _tmpVector;
  46338. private _tmpRotationMatrix;
  46339. /**
  46340. * 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)
  46341. */
  46342. ignoreChildren: boolean;
  46343. /**
  46344. * 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)
  46345. */
  46346. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46347. /**
  46348. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46349. */
  46350. rotationSphereSize: number;
  46351. /**
  46352. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46353. */
  46354. scaleBoxSize: number;
  46355. /**
  46356. * 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)
  46357. */
  46358. fixedDragMeshScreenSize: boolean;
  46359. /**
  46360. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46361. */
  46362. fixedDragMeshScreenSizeDistanceFactor: number;
  46363. /**
  46364. * Fired when a rotation sphere or scale box is dragged
  46365. */
  46366. onDragStartObservable: Observable<{}>;
  46367. /**
  46368. * Fired when a scale box is dragged
  46369. */
  46370. onScaleBoxDragObservable: Observable<{}>;
  46371. /**
  46372. * Fired when a scale box drag is ended
  46373. */
  46374. onScaleBoxDragEndObservable: Observable<{}>;
  46375. /**
  46376. * Fired when a rotation sphere is dragged
  46377. */
  46378. onRotationSphereDragObservable: Observable<{}>;
  46379. /**
  46380. * Fired when a rotation sphere drag is ended
  46381. */
  46382. onRotationSphereDragEndObservable: Observable<{}>;
  46383. /**
  46384. * 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)
  46385. */
  46386. scalePivot: Nullable<Vector3>;
  46387. /**
  46388. * Mesh used as a pivot to rotate the attached mesh
  46389. */
  46390. private _anchorMesh;
  46391. private _existingMeshScale;
  46392. private _dragMesh;
  46393. private pointerDragBehavior;
  46394. private coloredMaterial;
  46395. private hoverColoredMaterial;
  46396. /**
  46397. * Sets the color of the bounding box gizmo
  46398. * @param color the color to set
  46399. */
  46400. setColor(color: Color3): void;
  46401. /**
  46402. * Creates an BoundingBoxGizmo
  46403. * @param gizmoLayer The utility layer the gizmo will be added to
  46404. * @param color The color of the gizmo
  46405. */
  46406. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46407. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46408. private _selectNode;
  46409. /**
  46410. * Updates the bounding box information for the Gizmo
  46411. */
  46412. updateBoundingBox(): void;
  46413. private _updateRotationSpheres;
  46414. private _updateScaleBoxes;
  46415. /**
  46416. * Enables rotation on the specified axis and disables rotation on the others
  46417. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46418. */
  46419. setEnabledRotationAxis(axis: string): void;
  46420. /**
  46421. * Enables/disables scaling
  46422. * @param enable if scaling should be enabled
  46423. */
  46424. setEnabledScaling(enable: boolean): void;
  46425. private _updateDummy;
  46426. /**
  46427. * Enables a pointer drag behavior on the bounding box of the gizmo
  46428. */
  46429. enableDragBehavior(): void;
  46430. /**
  46431. * Disposes of the gizmo
  46432. */
  46433. dispose(): void;
  46434. /**
  46435. * 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)
  46436. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  46437. * @returns the bounding box mesh with the passed in mesh as a child
  46438. */
  46439. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  46440. /**
  46441. * CustomMeshes are not supported by this gizmo
  46442. * @param mesh The mesh to replace the default mesh of the gizmo
  46443. */
  46444. setCustomMesh(mesh: Mesh): void;
  46445. }
  46446. }
  46447. declare module BABYLON {
  46448. /**
  46449. * Single plane rotation gizmo
  46450. */
  46451. export class PlaneRotationGizmo extends Gizmo {
  46452. /**
  46453. * Drag behavior responsible for the gizmos dragging interactions
  46454. */
  46455. dragBehavior: PointerDragBehavior;
  46456. private _pointerObserver;
  46457. /**
  46458. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  46459. */
  46460. snapDistance: number;
  46461. /**
  46462. * Event that fires each time the gizmo snaps to a new location.
  46463. * * snapDistance is the the change in distance
  46464. */
  46465. onSnapObservable: Observable<{
  46466. snapDistance: number;
  46467. }>;
  46468. private _isEnabled;
  46469. private _parent;
  46470. /**
  46471. * Creates a PlaneRotationGizmo
  46472. * @param gizmoLayer The utility layer the gizmo will be added to
  46473. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  46474. * @param color The color of the gizmo
  46475. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46476. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46477. */
  46478. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  46479. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46480. /**
  46481. * If the gizmo is enabled
  46482. */
  46483. isEnabled: boolean;
  46484. /**
  46485. * Disposes of the gizmo
  46486. */
  46487. dispose(): void;
  46488. }
  46489. }
  46490. declare module BABYLON {
  46491. /**
  46492. * Gizmo that enables rotating a mesh along 3 axis
  46493. */
  46494. export class RotationGizmo extends Gizmo {
  46495. /**
  46496. * Internal gizmo used for interactions on the x axis
  46497. */
  46498. xGizmo: PlaneRotationGizmo;
  46499. /**
  46500. * Internal gizmo used for interactions on the y axis
  46501. */
  46502. yGizmo: PlaneRotationGizmo;
  46503. /**
  46504. * Internal gizmo used for interactions on the z axis
  46505. */
  46506. zGizmo: PlaneRotationGizmo;
  46507. /** Fires an event when any of it's sub gizmos are dragged */
  46508. onDragStartObservable: Observable<unknown>;
  46509. /** Fires an event when any of it's sub gizmos are released from dragging */
  46510. onDragEndObservable: Observable<unknown>;
  46511. private _meshAttached;
  46512. attachedMesh: Nullable<AbstractMesh>;
  46513. /**
  46514. * Creates a RotationGizmo
  46515. * @param gizmoLayer The utility layer the gizmo will be added to
  46516. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46517. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46518. */
  46519. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  46520. updateGizmoRotationToMatchAttachedMesh: boolean;
  46521. /**
  46522. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46523. */
  46524. snapDistance: number;
  46525. /**
  46526. * Ratio for the scale of the gizmo (Default: 1)
  46527. */
  46528. scaleRatio: number;
  46529. /**
  46530. * Disposes of the gizmo
  46531. */
  46532. dispose(): void;
  46533. /**
  46534. * CustomMeshes are not supported by this gizmo
  46535. * @param mesh The mesh to replace the default mesh of the gizmo
  46536. */
  46537. setCustomMesh(mesh: Mesh): void;
  46538. }
  46539. }
  46540. declare module BABYLON {
  46541. /**
  46542. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46543. */
  46544. export class GizmoManager implements IDisposable {
  46545. private scene;
  46546. /**
  46547. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46548. */
  46549. gizmos: {
  46550. positionGizmo: Nullable<PositionGizmo>;
  46551. rotationGizmo: Nullable<RotationGizmo>;
  46552. scaleGizmo: Nullable<ScaleGizmo>;
  46553. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46554. };
  46555. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46556. clearGizmoOnEmptyPointerEvent: boolean;
  46557. /** Fires an event when the manager is attached to a mesh */
  46558. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46559. private _gizmosEnabled;
  46560. private _pointerObserver;
  46561. private _attachedMesh;
  46562. private _boundingBoxColor;
  46563. private _defaultUtilityLayer;
  46564. private _defaultKeepDepthUtilityLayer;
  46565. /**
  46566. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46567. */
  46568. boundingBoxDragBehavior: SixDofDragBehavior;
  46569. /**
  46570. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46571. */
  46572. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46573. /**
  46574. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46575. */
  46576. usePointerToAttachGizmos: boolean;
  46577. /**
  46578. * Utility layer that the bounding box gizmo belongs to
  46579. */
  46580. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46581. /**
  46582. * Utility layer that all gizmos besides bounding box belong to
  46583. */
  46584. readonly utilityLayer: UtilityLayerRenderer;
  46585. /**
  46586. * Instatiates a gizmo manager
  46587. * @param scene the scene to overlay the gizmos on top of
  46588. */
  46589. constructor(scene: Scene);
  46590. /**
  46591. * Attaches a set of gizmos to the specified mesh
  46592. * @param mesh The mesh the gizmo's should be attached to
  46593. */
  46594. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46595. /**
  46596. * If the position gizmo is enabled
  46597. */
  46598. positionGizmoEnabled: boolean;
  46599. /**
  46600. * If the rotation gizmo is enabled
  46601. */
  46602. rotationGizmoEnabled: boolean;
  46603. /**
  46604. * If the scale gizmo is enabled
  46605. */
  46606. scaleGizmoEnabled: boolean;
  46607. /**
  46608. * If the boundingBox gizmo is enabled
  46609. */
  46610. boundingBoxGizmoEnabled: boolean;
  46611. /**
  46612. * Disposes of the gizmo manager
  46613. */
  46614. dispose(): void;
  46615. }
  46616. }
  46617. declare module BABYLON {
  46618. /**
  46619. * A directional light is defined by a direction (what a surprise!).
  46620. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46621. * 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.
  46622. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46623. */
  46624. export class DirectionalLight extends ShadowLight {
  46625. private _shadowFrustumSize;
  46626. /**
  46627. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46628. */
  46629. /**
  46630. * Specifies a fix frustum size for the shadow generation.
  46631. */
  46632. shadowFrustumSize: number;
  46633. private _shadowOrthoScale;
  46634. /**
  46635. * Gets the shadow projection scale against the optimal computed one.
  46636. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46637. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46638. */
  46639. /**
  46640. * Sets the shadow projection scale against the optimal computed one.
  46641. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46642. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46643. */
  46644. shadowOrthoScale: number;
  46645. /**
  46646. * Automatically compute the projection matrix to best fit (including all the casters)
  46647. * on each frame.
  46648. */
  46649. autoUpdateExtends: boolean;
  46650. private _orthoLeft;
  46651. private _orthoRight;
  46652. private _orthoTop;
  46653. private _orthoBottom;
  46654. /**
  46655. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46656. * The directional light is emitted from everywhere in the given direction.
  46657. * It can cast shadows.
  46658. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46659. * @param name The friendly name of the light
  46660. * @param direction The direction of the light
  46661. * @param scene The scene the light belongs to
  46662. */
  46663. constructor(name: string, direction: Vector3, scene: Scene);
  46664. /**
  46665. * Returns the string "DirectionalLight".
  46666. * @return The class name
  46667. */
  46668. getClassName(): string;
  46669. /**
  46670. * Returns the integer 1.
  46671. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46672. */
  46673. getTypeID(): number;
  46674. /**
  46675. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46676. * Returns the DirectionalLight Shadow projection matrix.
  46677. */
  46678. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46679. /**
  46680. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46681. * Returns the DirectionalLight Shadow projection matrix.
  46682. */
  46683. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46684. /**
  46685. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46686. * Returns the DirectionalLight Shadow projection matrix.
  46687. */
  46688. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46689. protected _buildUniformLayout(): void;
  46690. /**
  46691. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46692. * @param effect The effect to update
  46693. * @param lightIndex The index of the light in the effect to update
  46694. * @returns The directional light
  46695. */
  46696. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46697. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  46698. /**
  46699. * Gets the minZ used for shadow according to both the scene and the light.
  46700. *
  46701. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46702. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46703. * @param activeCamera The camera we are returning the min for
  46704. * @returns the depth min z
  46705. */
  46706. getDepthMinZ(activeCamera: Camera): number;
  46707. /**
  46708. * Gets the maxZ used for shadow according to both the scene and the light.
  46709. *
  46710. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46711. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46712. * @param activeCamera The camera we are returning the max for
  46713. * @returns the depth max z
  46714. */
  46715. getDepthMaxZ(activeCamera: Camera): number;
  46716. /**
  46717. * Prepares the list of defines specific to the light type.
  46718. * @param defines the list of defines
  46719. * @param lightIndex defines the index of the light for the effect
  46720. */
  46721. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46722. }
  46723. }
  46724. declare module BABYLON {
  46725. /**
  46726. * Class containing static functions to help procedurally build meshes
  46727. */
  46728. export class HemisphereBuilder {
  46729. /**
  46730. * Creates a hemisphere mesh
  46731. * @param name defines the name of the mesh
  46732. * @param options defines the options used to create the mesh
  46733. * @param scene defines the hosting scene
  46734. * @returns the hemisphere mesh
  46735. */
  46736. static CreateHemisphere(name: string, options: {
  46737. segments?: number;
  46738. diameter?: number;
  46739. sideOrientation?: number;
  46740. }, scene: any): Mesh;
  46741. }
  46742. }
  46743. declare module BABYLON {
  46744. /**
  46745. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46746. * These values define a cone of light starting from the position, emitting toward the direction.
  46747. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46748. * and the exponent defines the speed of the decay of the light with distance (reach).
  46749. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46750. */
  46751. export class SpotLight extends ShadowLight {
  46752. private _angle;
  46753. private _innerAngle;
  46754. private _cosHalfAngle;
  46755. private _lightAngleScale;
  46756. private _lightAngleOffset;
  46757. /**
  46758. * Gets the cone angle of the spot light in Radians.
  46759. */
  46760. /**
  46761. * Sets the cone angle of the spot light in Radians.
  46762. */
  46763. angle: number;
  46764. /**
  46765. * Only used in gltf falloff mode, this defines the angle where
  46766. * the directional falloff will start before cutting at angle which could be seen
  46767. * as outer angle.
  46768. */
  46769. /**
  46770. * Only used in gltf falloff mode, this defines the angle where
  46771. * the directional falloff will start before cutting at angle which could be seen
  46772. * as outer angle.
  46773. */
  46774. innerAngle: number;
  46775. private _shadowAngleScale;
  46776. /**
  46777. * Allows scaling the angle of the light for shadow generation only.
  46778. */
  46779. /**
  46780. * Allows scaling the angle of the light for shadow generation only.
  46781. */
  46782. shadowAngleScale: number;
  46783. /**
  46784. * The light decay speed with the distance from the emission spot.
  46785. */
  46786. exponent: number;
  46787. private _projectionTextureMatrix;
  46788. /**
  46789. * Allows reading the projecton texture
  46790. */
  46791. readonly projectionTextureMatrix: Matrix;
  46792. protected _projectionTextureLightNear: number;
  46793. /**
  46794. * Gets the near clip of the Spotlight for texture projection.
  46795. */
  46796. /**
  46797. * Sets the near clip of the Spotlight for texture projection.
  46798. */
  46799. projectionTextureLightNear: number;
  46800. protected _projectionTextureLightFar: number;
  46801. /**
  46802. * Gets the far clip of the Spotlight for texture projection.
  46803. */
  46804. /**
  46805. * Sets the far clip of the Spotlight for texture projection.
  46806. */
  46807. projectionTextureLightFar: number;
  46808. protected _projectionTextureUpDirection: Vector3;
  46809. /**
  46810. * Gets the Up vector of the Spotlight for texture projection.
  46811. */
  46812. /**
  46813. * Sets the Up vector of the Spotlight for texture projection.
  46814. */
  46815. projectionTextureUpDirection: Vector3;
  46816. private _projectionTexture;
  46817. /**
  46818. * Gets the projection texture of the light.
  46819. */
  46820. /**
  46821. * Sets the projection texture of the light.
  46822. */
  46823. projectionTexture: Nullable<BaseTexture>;
  46824. private _projectionTextureViewLightDirty;
  46825. private _projectionTextureProjectionLightDirty;
  46826. private _projectionTextureDirty;
  46827. private _projectionTextureViewTargetVector;
  46828. private _projectionTextureViewLightMatrix;
  46829. private _projectionTextureProjectionLightMatrix;
  46830. private _projectionTextureScalingMatrix;
  46831. /**
  46832. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46833. * It can cast shadows.
  46834. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46835. * @param name The light friendly name
  46836. * @param position The position of the spot light in the scene
  46837. * @param direction The direction of the light in the scene
  46838. * @param angle The cone angle of the light in Radians
  46839. * @param exponent The light decay speed with the distance from the emission spot
  46840. * @param scene The scene the lights belongs to
  46841. */
  46842. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46843. /**
  46844. * Returns the string "SpotLight".
  46845. * @returns the class name
  46846. */
  46847. getClassName(): string;
  46848. /**
  46849. * Returns the integer 2.
  46850. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46851. */
  46852. getTypeID(): number;
  46853. /**
  46854. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46855. */
  46856. protected _setDirection(value: Vector3): void;
  46857. /**
  46858. * Overrides the position setter to recompute the projection texture view light Matrix.
  46859. */
  46860. protected _setPosition(value: Vector3): void;
  46861. /**
  46862. * 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.
  46863. * Returns the SpotLight.
  46864. */
  46865. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46866. protected _computeProjectionTextureViewLightMatrix(): void;
  46867. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46868. /**
  46869. * Main function for light texture projection matrix computing.
  46870. */
  46871. protected _computeProjectionTextureMatrix(): void;
  46872. protected _buildUniformLayout(): void;
  46873. private _computeAngleValues;
  46874. /**
  46875. * Sets the passed Effect "effect" with the Light textures.
  46876. * @param effect The effect to update
  46877. * @param lightIndex The index of the light in the effect to update
  46878. * @returns The light
  46879. */
  46880. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  46881. /**
  46882. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46883. * @param effect The effect to update
  46884. * @param lightIndex The index of the light in the effect to update
  46885. * @returns The spot light
  46886. */
  46887. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46888. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  46889. /**
  46890. * Disposes the light and the associated resources.
  46891. */
  46892. dispose(): void;
  46893. /**
  46894. * Prepares the list of defines specific to the light type.
  46895. * @param defines the list of defines
  46896. * @param lightIndex defines the index of the light for the effect
  46897. */
  46898. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46899. }
  46900. }
  46901. declare module BABYLON {
  46902. /**
  46903. * Gizmo that enables viewing a light
  46904. */
  46905. export class LightGizmo extends Gizmo {
  46906. private _lightMesh;
  46907. private _material;
  46908. private _cachedPosition;
  46909. private _cachedForward;
  46910. private _attachedMeshParent;
  46911. /**
  46912. * Creates a LightGizmo
  46913. * @param gizmoLayer The utility layer the gizmo will be added to
  46914. */
  46915. constructor(gizmoLayer?: UtilityLayerRenderer);
  46916. private _light;
  46917. /**
  46918. * The light that the gizmo is attached to
  46919. */
  46920. light: Nullable<Light>;
  46921. /**
  46922. * Gets the material used to render the light gizmo
  46923. */
  46924. readonly material: StandardMaterial;
  46925. /**
  46926. * @hidden
  46927. * Updates the gizmo to match the attached mesh's position/rotation
  46928. */
  46929. protected _update(): void;
  46930. private static _Scale;
  46931. /**
  46932. * Creates the lines for a light mesh
  46933. */
  46934. private static _CreateLightLines;
  46935. /**
  46936. * Disposes of the light gizmo
  46937. */
  46938. dispose(): void;
  46939. private static _CreateHemisphericLightMesh;
  46940. private static _CreatePointLightMesh;
  46941. private static _CreateSpotLightMesh;
  46942. private static _CreateDirectionalLightMesh;
  46943. }
  46944. }
  46945. declare module BABYLON {
  46946. /** @hidden */
  46947. export var backgroundFragmentDeclaration: {
  46948. name: string;
  46949. shader: string;
  46950. };
  46951. }
  46952. declare module BABYLON {
  46953. /** @hidden */
  46954. export var backgroundUboDeclaration: {
  46955. name: string;
  46956. shader: string;
  46957. };
  46958. }
  46959. declare module BABYLON {
  46960. /** @hidden */
  46961. export var backgroundPixelShader: {
  46962. name: string;
  46963. shader: string;
  46964. };
  46965. }
  46966. declare module BABYLON {
  46967. /** @hidden */
  46968. export var backgroundVertexDeclaration: {
  46969. name: string;
  46970. shader: string;
  46971. };
  46972. }
  46973. declare module BABYLON {
  46974. /** @hidden */
  46975. export var backgroundVertexShader: {
  46976. name: string;
  46977. shader: string;
  46978. };
  46979. }
  46980. declare module BABYLON {
  46981. /**
  46982. * Background material used to create an efficient environement around your scene.
  46983. */
  46984. export class BackgroundMaterial extends PushMaterial {
  46985. /**
  46986. * Standard reflectance value at parallel view angle.
  46987. */
  46988. static StandardReflectance0: number;
  46989. /**
  46990. * Standard reflectance value at grazing angle.
  46991. */
  46992. static StandardReflectance90: number;
  46993. protected _primaryColor: Color3;
  46994. /**
  46995. * Key light Color (multiply against the environement texture)
  46996. */
  46997. primaryColor: Color3;
  46998. protected __perceptualColor: Nullable<Color3>;
  46999. /**
  47000. * Experimental Internal Use Only.
  47001. *
  47002. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47003. * This acts as a helper to set the primary color to a more "human friendly" value.
  47004. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47005. * output color as close as possible from the chosen value.
  47006. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47007. * part of lighting setup.)
  47008. */
  47009. _perceptualColor: Nullable<Color3>;
  47010. protected _primaryColorShadowLevel: float;
  47011. /**
  47012. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47013. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47014. */
  47015. primaryColorShadowLevel: float;
  47016. protected _primaryColorHighlightLevel: float;
  47017. /**
  47018. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47019. * The primary color is used at the level chosen to define what the white area would look.
  47020. */
  47021. primaryColorHighlightLevel: float;
  47022. protected _reflectionTexture: Nullable<BaseTexture>;
  47023. /**
  47024. * Reflection Texture used in the material.
  47025. * Should be author in a specific way for the best result (refer to the documentation).
  47026. */
  47027. reflectionTexture: Nullable<BaseTexture>;
  47028. protected _reflectionBlur: float;
  47029. /**
  47030. * Reflection Texture level of blur.
  47031. *
  47032. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47033. * texture twice.
  47034. */
  47035. reflectionBlur: float;
  47036. protected _diffuseTexture: Nullable<BaseTexture>;
  47037. /**
  47038. * Diffuse Texture used in the material.
  47039. * Should be author in a specific way for the best result (refer to the documentation).
  47040. */
  47041. diffuseTexture: Nullable<BaseTexture>;
  47042. protected _shadowLights: Nullable<IShadowLight[]>;
  47043. /**
  47044. * Specify the list of lights casting shadow on the material.
  47045. * All scene shadow lights will be included if null.
  47046. */
  47047. shadowLights: Nullable<IShadowLight[]>;
  47048. protected _shadowLevel: float;
  47049. /**
  47050. * Helps adjusting the shadow to a softer level if required.
  47051. * 0 means black shadows and 1 means no shadows.
  47052. */
  47053. shadowLevel: float;
  47054. protected _sceneCenter: Vector3;
  47055. /**
  47056. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47057. * It is usually zero but might be interesting to modify according to your setup.
  47058. */
  47059. sceneCenter: Vector3;
  47060. protected _opacityFresnel: boolean;
  47061. /**
  47062. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47063. * This helps ensuring a nice transition when the camera goes under the ground.
  47064. */
  47065. opacityFresnel: boolean;
  47066. protected _reflectionFresnel: boolean;
  47067. /**
  47068. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47069. * This helps adding a mirror texture on the ground.
  47070. */
  47071. reflectionFresnel: boolean;
  47072. protected _reflectionFalloffDistance: number;
  47073. /**
  47074. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47075. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47076. */
  47077. reflectionFalloffDistance: number;
  47078. protected _reflectionAmount: number;
  47079. /**
  47080. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47081. */
  47082. reflectionAmount: number;
  47083. protected _reflectionReflectance0: number;
  47084. /**
  47085. * This specifies the weight of the reflection at grazing angle.
  47086. */
  47087. reflectionReflectance0: number;
  47088. protected _reflectionReflectance90: number;
  47089. /**
  47090. * This specifies the weight of the reflection at a perpendicular point of view.
  47091. */
  47092. reflectionReflectance90: number;
  47093. /**
  47094. * Sets the reflection reflectance fresnel values according to the default standard
  47095. * empirically know to work well :-)
  47096. */
  47097. reflectionStandardFresnelWeight: number;
  47098. protected _useRGBColor: boolean;
  47099. /**
  47100. * Helps to directly use the maps channels instead of their level.
  47101. */
  47102. useRGBColor: boolean;
  47103. protected _enableNoise: boolean;
  47104. /**
  47105. * This helps reducing the banding effect that could occur on the background.
  47106. */
  47107. enableNoise: boolean;
  47108. /**
  47109. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47110. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47111. * Recommended to be keep at 1.0 except for special cases.
  47112. */
  47113. fovMultiplier: number;
  47114. private _fovMultiplier;
  47115. /**
  47116. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47117. */
  47118. useEquirectangularFOV: boolean;
  47119. private _maxSimultaneousLights;
  47120. /**
  47121. * Number of Simultaneous lights allowed on the material.
  47122. */
  47123. maxSimultaneousLights: int;
  47124. /**
  47125. * Default configuration related to image processing available in the Background Material.
  47126. */
  47127. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47128. /**
  47129. * Keep track of the image processing observer to allow dispose and replace.
  47130. */
  47131. private _imageProcessingObserver;
  47132. /**
  47133. * Attaches a new image processing configuration to the PBR Material.
  47134. * @param configuration (if null the scene configuration will be use)
  47135. */
  47136. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47137. /**
  47138. * Gets the image processing configuration used either in this material.
  47139. */
  47140. /**
  47141. * Sets the Default image processing configuration used either in the this material.
  47142. *
  47143. * If sets to null, the scene one is in use.
  47144. */
  47145. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47146. /**
  47147. * Gets wether the color curves effect is enabled.
  47148. */
  47149. /**
  47150. * Sets wether the color curves effect is enabled.
  47151. */
  47152. cameraColorCurvesEnabled: boolean;
  47153. /**
  47154. * Gets wether the color grading effect is enabled.
  47155. */
  47156. /**
  47157. * Gets wether the color grading effect is enabled.
  47158. */
  47159. cameraColorGradingEnabled: boolean;
  47160. /**
  47161. * Gets wether tonemapping is enabled or not.
  47162. */
  47163. /**
  47164. * Sets wether tonemapping is enabled or not
  47165. */
  47166. cameraToneMappingEnabled: boolean;
  47167. /**
  47168. * The camera exposure used on this material.
  47169. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47170. * This corresponds to a photographic exposure.
  47171. */
  47172. /**
  47173. * The camera exposure used on this material.
  47174. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47175. * This corresponds to a photographic exposure.
  47176. */
  47177. cameraExposure: float;
  47178. /**
  47179. * Gets The camera contrast used on this material.
  47180. */
  47181. /**
  47182. * Sets The camera contrast used on this material.
  47183. */
  47184. cameraContrast: float;
  47185. /**
  47186. * Gets the Color Grading 2D Lookup Texture.
  47187. */
  47188. /**
  47189. * Sets the Color Grading 2D Lookup Texture.
  47190. */
  47191. cameraColorGradingTexture: Nullable<BaseTexture>;
  47192. /**
  47193. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47194. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47195. * 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;
  47196. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47197. */
  47198. /**
  47199. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47200. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47201. * 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;
  47202. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47203. */
  47204. cameraColorCurves: Nullable<ColorCurves>;
  47205. /**
  47206. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47207. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47208. */
  47209. switchToBGR: boolean;
  47210. private _renderTargets;
  47211. private _reflectionControls;
  47212. private _white;
  47213. private _primaryShadowColor;
  47214. private _primaryHighlightColor;
  47215. /**
  47216. * Instantiates a Background Material in the given scene
  47217. * @param name The friendly name of the material
  47218. * @param scene The scene to add the material to
  47219. */
  47220. constructor(name: string, scene: Scene);
  47221. /**
  47222. * Gets a boolean indicating that current material needs to register RTT
  47223. */
  47224. readonly hasRenderTargetTextures: boolean;
  47225. /**
  47226. * The entire material has been created in order to prevent overdraw.
  47227. * @returns false
  47228. */
  47229. needAlphaTesting(): boolean;
  47230. /**
  47231. * The entire material has been created in order to prevent overdraw.
  47232. * @returns true if blending is enable
  47233. */
  47234. needAlphaBlending(): boolean;
  47235. /**
  47236. * Checks wether the material is ready to be rendered for a given mesh.
  47237. * @param mesh The mesh to render
  47238. * @param subMesh The submesh to check against
  47239. * @param useInstances Specify wether or not the material is used with instances
  47240. * @returns true if all the dependencies are ready (Textures, Effects...)
  47241. */
  47242. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47243. /**
  47244. * Compute the primary color according to the chosen perceptual color.
  47245. */
  47246. private _computePrimaryColorFromPerceptualColor;
  47247. /**
  47248. * Compute the highlights and shadow colors according to their chosen levels.
  47249. */
  47250. private _computePrimaryColors;
  47251. /**
  47252. * Build the uniform buffer used in the material.
  47253. */
  47254. buildUniformLayout(): void;
  47255. /**
  47256. * Unbind the material.
  47257. */
  47258. unbind(): void;
  47259. /**
  47260. * Bind only the world matrix to the material.
  47261. * @param world The world matrix to bind.
  47262. */
  47263. bindOnlyWorldMatrix(world: Matrix): void;
  47264. /**
  47265. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47266. * @param world The world matrix to bind.
  47267. * @param subMesh The submesh to bind for.
  47268. */
  47269. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47270. /**
  47271. * Checks to see if a texture is used in the material.
  47272. * @param texture - Base texture to use.
  47273. * @returns - Boolean specifying if a texture is used in the material.
  47274. */
  47275. hasTexture(texture: BaseTexture): boolean;
  47276. /**
  47277. * Dispose the material.
  47278. * @param forceDisposeEffect Force disposal of the associated effect.
  47279. * @param forceDisposeTextures Force disposal of the associated textures.
  47280. */
  47281. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47282. /**
  47283. * Clones the material.
  47284. * @param name The cloned name.
  47285. * @returns The cloned material.
  47286. */
  47287. clone(name: string): BackgroundMaterial;
  47288. /**
  47289. * Serializes the current material to its JSON representation.
  47290. * @returns The JSON representation.
  47291. */
  47292. serialize(): any;
  47293. /**
  47294. * Gets the class name of the material
  47295. * @returns "BackgroundMaterial"
  47296. */
  47297. getClassName(): string;
  47298. /**
  47299. * Parse a JSON input to create back a background material.
  47300. * @param source The JSON data to parse
  47301. * @param scene The scene to create the parsed material in
  47302. * @param rootUrl The root url of the assets the material depends upon
  47303. * @returns the instantiated BackgroundMaterial.
  47304. */
  47305. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47306. }
  47307. }
  47308. declare module BABYLON {
  47309. /**
  47310. * Represents the different options available during the creation of
  47311. * a Environment helper.
  47312. *
  47313. * This can control the default ground, skybox and image processing setup of your scene.
  47314. */
  47315. export interface IEnvironmentHelperOptions {
  47316. /**
  47317. * Specifies wether or not to create a ground.
  47318. * True by default.
  47319. */
  47320. createGround: boolean;
  47321. /**
  47322. * Specifies the ground size.
  47323. * 15 by default.
  47324. */
  47325. groundSize: number;
  47326. /**
  47327. * The texture used on the ground for the main color.
  47328. * Comes from the BabylonJS CDN by default.
  47329. *
  47330. * Remarks: Can be either a texture or a url.
  47331. */
  47332. groundTexture: string | BaseTexture;
  47333. /**
  47334. * The color mixed in the ground texture by default.
  47335. * BabylonJS clearColor by default.
  47336. */
  47337. groundColor: Color3;
  47338. /**
  47339. * Specifies the ground opacity.
  47340. * 1 by default.
  47341. */
  47342. groundOpacity: number;
  47343. /**
  47344. * Enables the ground to receive shadows.
  47345. * True by default.
  47346. */
  47347. enableGroundShadow: boolean;
  47348. /**
  47349. * Helps preventing the shadow to be fully black on the ground.
  47350. * 0.5 by default.
  47351. */
  47352. groundShadowLevel: number;
  47353. /**
  47354. * Creates a mirror texture attach to the ground.
  47355. * false by default.
  47356. */
  47357. enableGroundMirror: boolean;
  47358. /**
  47359. * Specifies the ground mirror size ratio.
  47360. * 0.3 by default as the default kernel is 64.
  47361. */
  47362. groundMirrorSizeRatio: number;
  47363. /**
  47364. * Specifies the ground mirror blur kernel size.
  47365. * 64 by default.
  47366. */
  47367. groundMirrorBlurKernel: number;
  47368. /**
  47369. * Specifies the ground mirror visibility amount.
  47370. * 1 by default
  47371. */
  47372. groundMirrorAmount: number;
  47373. /**
  47374. * Specifies the ground mirror reflectance weight.
  47375. * This uses the standard weight of the background material to setup the fresnel effect
  47376. * of the mirror.
  47377. * 1 by default.
  47378. */
  47379. groundMirrorFresnelWeight: number;
  47380. /**
  47381. * Specifies the ground mirror Falloff distance.
  47382. * This can helps reducing the size of the reflection.
  47383. * 0 by Default.
  47384. */
  47385. groundMirrorFallOffDistance: number;
  47386. /**
  47387. * Specifies the ground mirror texture type.
  47388. * Unsigned Int by Default.
  47389. */
  47390. groundMirrorTextureType: number;
  47391. /**
  47392. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  47393. * the shown objects.
  47394. */
  47395. groundYBias: number;
  47396. /**
  47397. * Specifies wether or not to create a skybox.
  47398. * True by default.
  47399. */
  47400. createSkybox: boolean;
  47401. /**
  47402. * Specifies the skybox size.
  47403. * 20 by default.
  47404. */
  47405. skyboxSize: number;
  47406. /**
  47407. * The texture used on the skybox for the main color.
  47408. * Comes from the BabylonJS CDN by default.
  47409. *
  47410. * Remarks: Can be either a texture or a url.
  47411. */
  47412. skyboxTexture: string | BaseTexture;
  47413. /**
  47414. * The color mixed in the skybox texture by default.
  47415. * BabylonJS clearColor by default.
  47416. */
  47417. skyboxColor: Color3;
  47418. /**
  47419. * The background rotation around the Y axis of the scene.
  47420. * This helps aligning the key lights of your scene with the background.
  47421. * 0 by default.
  47422. */
  47423. backgroundYRotation: number;
  47424. /**
  47425. * Compute automatically the size of the elements to best fit with the scene.
  47426. */
  47427. sizeAuto: boolean;
  47428. /**
  47429. * Default position of the rootMesh if autoSize is not true.
  47430. */
  47431. rootPosition: Vector3;
  47432. /**
  47433. * Sets up the image processing in the scene.
  47434. * true by default.
  47435. */
  47436. setupImageProcessing: boolean;
  47437. /**
  47438. * The texture used as your environment texture in the scene.
  47439. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  47440. *
  47441. * Remarks: Can be either a texture or a url.
  47442. */
  47443. environmentTexture: string | BaseTexture;
  47444. /**
  47445. * The value of the exposure to apply to the scene.
  47446. * 0.6 by default if setupImageProcessing is true.
  47447. */
  47448. cameraExposure: number;
  47449. /**
  47450. * The value of the contrast to apply to the scene.
  47451. * 1.6 by default if setupImageProcessing is true.
  47452. */
  47453. cameraContrast: number;
  47454. /**
  47455. * Specifies wether or not tonemapping should be enabled in the scene.
  47456. * true by default if setupImageProcessing is true.
  47457. */
  47458. toneMappingEnabled: boolean;
  47459. }
  47460. /**
  47461. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  47462. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  47463. * It also helps with the default setup of your imageProcessing configuration.
  47464. */
  47465. export class EnvironmentHelper {
  47466. /**
  47467. * Default ground texture URL.
  47468. */
  47469. private static _groundTextureCDNUrl;
  47470. /**
  47471. * Default skybox texture URL.
  47472. */
  47473. private static _skyboxTextureCDNUrl;
  47474. /**
  47475. * Default environment texture URL.
  47476. */
  47477. private static _environmentTextureCDNUrl;
  47478. /**
  47479. * Creates the default options for the helper.
  47480. */
  47481. private static _getDefaultOptions;
  47482. private _rootMesh;
  47483. /**
  47484. * Gets the root mesh created by the helper.
  47485. */
  47486. readonly rootMesh: Mesh;
  47487. private _skybox;
  47488. /**
  47489. * Gets the skybox created by the helper.
  47490. */
  47491. readonly skybox: Nullable<Mesh>;
  47492. private _skyboxTexture;
  47493. /**
  47494. * Gets the skybox texture created by the helper.
  47495. */
  47496. readonly skyboxTexture: Nullable<BaseTexture>;
  47497. private _skyboxMaterial;
  47498. /**
  47499. * Gets the skybox material created by the helper.
  47500. */
  47501. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47502. private _ground;
  47503. /**
  47504. * Gets the ground mesh created by the helper.
  47505. */
  47506. readonly ground: Nullable<Mesh>;
  47507. private _groundTexture;
  47508. /**
  47509. * Gets the ground texture created by the helper.
  47510. */
  47511. readonly groundTexture: Nullable<BaseTexture>;
  47512. private _groundMirror;
  47513. /**
  47514. * Gets the ground mirror created by the helper.
  47515. */
  47516. readonly groundMirror: Nullable<MirrorTexture>;
  47517. /**
  47518. * Gets the ground mirror render list to helps pushing the meshes
  47519. * you wish in the ground reflection.
  47520. */
  47521. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47522. private _groundMaterial;
  47523. /**
  47524. * Gets the ground material created by the helper.
  47525. */
  47526. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47527. /**
  47528. * Stores the creation options.
  47529. */
  47530. private readonly _scene;
  47531. private _options;
  47532. /**
  47533. * This observable will be notified with any error during the creation of the environment,
  47534. * mainly texture creation errors.
  47535. */
  47536. onErrorObservable: Observable<{
  47537. message?: string;
  47538. exception?: any;
  47539. }>;
  47540. /**
  47541. * constructor
  47542. * @param options Defines the options we want to customize the helper
  47543. * @param scene The scene to add the material to
  47544. */
  47545. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47546. /**
  47547. * Updates the background according to the new options
  47548. * @param options
  47549. */
  47550. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47551. /**
  47552. * Sets the primary color of all the available elements.
  47553. * @param color the main color to affect to the ground and the background
  47554. */
  47555. setMainColor(color: Color3): void;
  47556. /**
  47557. * Setup the image processing according to the specified options.
  47558. */
  47559. private _setupImageProcessing;
  47560. /**
  47561. * Setup the environment texture according to the specified options.
  47562. */
  47563. private _setupEnvironmentTexture;
  47564. /**
  47565. * Setup the background according to the specified options.
  47566. */
  47567. private _setupBackground;
  47568. /**
  47569. * Get the scene sizes according to the setup.
  47570. */
  47571. private _getSceneSize;
  47572. /**
  47573. * Setup the ground according to the specified options.
  47574. */
  47575. private _setupGround;
  47576. /**
  47577. * Setup the ground material according to the specified options.
  47578. */
  47579. private _setupGroundMaterial;
  47580. /**
  47581. * Setup the ground diffuse texture according to the specified options.
  47582. */
  47583. private _setupGroundDiffuseTexture;
  47584. /**
  47585. * Setup the ground mirror texture according to the specified options.
  47586. */
  47587. private _setupGroundMirrorTexture;
  47588. /**
  47589. * Setup the ground to receive the mirror texture.
  47590. */
  47591. private _setupMirrorInGroundMaterial;
  47592. /**
  47593. * Setup the skybox according to the specified options.
  47594. */
  47595. private _setupSkybox;
  47596. /**
  47597. * Setup the skybox material according to the specified options.
  47598. */
  47599. private _setupSkyboxMaterial;
  47600. /**
  47601. * Setup the skybox reflection texture according to the specified options.
  47602. */
  47603. private _setupSkyboxReflectionTexture;
  47604. private _errorHandler;
  47605. /**
  47606. * Dispose all the elements created by the Helper.
  47607. */
  47608. dispose(): void;
  47609. }
  47610. }
  47611. declare module BABYLON {
  47612. /**
  47613. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47614. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47615. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47616. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47617. */
  47618. export class PhotoDome extends TransformNode {
  47619. /**
  47620. * Define the image as a Monoscopic panoramic 360 image.
  47621. */
  47622. static readonly MODE_MONOSCOPIC: number;
  47623. /**
  47624. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47625. */
  47626. static readonly MODE_TOPBOTTOM: number;
  47627. /**
  47628. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47629. */
  47630. static readonly MODE_SIDEBYSIDE: number;
  47631. private _useDirectMapping;
  47632. /**
  47633. * The texture being displayed on the sphere
  47634. */
  47635. protected _photoTexture: Texture;
  47636. /**
  47637. * Gets or sets the texture being displayed on the sphere
  47638. */
  47639. photoTexture: Texture;
  47640. /**
  47641. * Observable raised when an error occured while loading the 360 image
  47642. */
  47643. onLoadErrorObservable: Observable<string>;
  47644. /**
  47645. * The skybox material
  47646. */
  47647. protected _material: BackgroundMaterial;
  47648. /**
  47649. * The surface used for the skybox
  47650. */
  47651. protected _mesh: Mesh;
  47652. /**
  47653. * Gets the mesh used for the skybox.
  47654. */
  47655. readonly mesh: Mesh;
  47656. /**
  47657. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47658. * Also see the options.resolution property.
  47659. */
  47660. fovMultiplier: number;
  47661. private _imageMode;
  47662. /**
  47663. * Gets or set the current video mode for the video. It can be:
  47664. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47665. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47666. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47667. */
  47668. imageMode: number;
  47669. /**
  47670. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47671. * @param name Element's name, child elements will append suffixes for their own names.
  47672. * @param urlsOfPhoto defines the url of the photo to display
  47673. * @param options defines an object containing optional or exposed sub element properties
  47674. * @param onError defines a callback called when an error occured while loading the texture
  47675. */
  47676. constructor(name: string, urlOfPhoto: string, options: {
  47677. resolution?: number;
  47678. size?: number;
  47679. useDirectMapping?: boolean;
  47680. faceForward?: boolean;
  47681. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47682. private _onBeforeCameraRenderObserver;
  47683. private _changeImageMode;
  47684. /**
  47685. * Releases resources associated with this node.
  47686. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47687. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47688. */
  47689. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47690. }
  47691. }
  47692. declare module BABYLON {
  47693. /**
  47694. * Class used to host RGBD texture specific utilities
  47695. */
  47696. export class RGBDTextureTools {
  47697. /**
  47698. * Expand the RGBD Texture from RGBD to Half Float if possible.
  47699. * @param texture the texture to expand.
  47700. */
  47701. static ExpandRGBDTexture(texture: Texture): void;
  47702. }
  47703. }
  47704. declare module BABYLON {
  47705. /**
  47706. * Class used to host texture specific utilities
  47707. */
  47708. export class BRDFTextureTools {
  47709. /**
  47710. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47711. * @param scene defines the hosting scene
  47712. * @returns the environment BRDF texture
  47713. */
  47714. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47715. private static _environmentBRDFBase64Texture;
  47716. }
  47717. }
  47718. declare module BABYLON {
  47719. /**
  47720. * @hidden
  47721. */
  47722. export interface IMaterialClearCoatDefines {
  47723. CLEARCOAT: boolean;
  47724. CLEARCOAT_DEFAULTIOR: boolean;
  47725. CLEARCOAT_TEXTURE: boolean;
  47726. CLEARCOAT_TEXTUREDIRECTUV: number;
  47727. CLEARCOAT_BUMP: boolean;
  47728. CLEARCOAT_BUMPDIRECTUV: number;
  47729. CLEARCOAT_TINT: boolean;
  47730. CLEARCOAT_TINT_TEXTURE: boolean;
  47731. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47732. /** @hidden */
  47733. _areTexturesDirty: boolean;
  47734. }
  47735. /**
  47736. * Define the code related to the clear coat parameters of the pbr material.
  47737. */
  47738. export class PBRClearCoatConfiguration {
  47739. /**
  47740. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47741. * The default fits with a polyurethane material.
  47742. */
  47743. private static readonly _DefaultIndexOfRefraction;
  47744. private _isEnabled;
  47745. /**
  47746. * Defines if the clear coat is enabled in the material.
  47747. */
  47748. isEnabled: boolean;
  47749. /**
  47750. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47751. */
  47752. intensity: number;
  47753. /**
  47754. * Defines the clear coat layer roughness.
  47755. */
  47756. roughness: number;
  47757. private _indexOfRefraction;
  47758. /**
  47759. * Defines the index of refraction of the clear coat.
  47760. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47761. * The default fits with a polyurethane material.
  47762. * Changing the default value is more performance intensive.
  47763. */
  47764. indexOfRefraction: number;
  47765. private _texture;
  47766. /**
  47767. * Stores the clear coat values in a texture.
  47768. */
  47769. texture: Nullable<BaseTexture>;
  47770. private _bumpTexture;
  47771. /**
  47772. * Define the clear coat specific bump texture.
  47773. */
  47774. bumpTexture: Nullable<BaseTexture>;
  47775. private _isTintEnabled;
  47776. /**
  47777. * Defines if the clear coat tint is enabled in the material.
  47778. */
  47779. isTintEnabled: boolean;
  47780. /**
  47781. * Defines the clear coat tint of the material.
  47782. * This is only use if tint is enabled
  47783. */
  47784. tintColor: Color3;
  47785. /**
  47786. * Defines the distance at which the tint color should be found in the
  47787. * clear coat media.
  47788. * This is only use if tint is enabled
  47789. */
  47790. tintColorAtDistance: number;
  47791. /**
  47792. * Defines the clear coat layer thickness.
  47793. * This is only use if tint is enabled
  47794. */
  47795. tintThickness: number;
  47796. private _tintTexture;
  47797. /**
  47798. * Stores the clear tint values in a texture.
  47799. * rgb is tint
  47800. * a is a thickness factor
  47801. */
  47802. tintTexture: Nullable<BaseTexture>;
  47803. /** @hidden */
  47804. private _internalMarkAllSubMeshesAsTexturesDirty;
  47805. /** @hidden */
  47806. _markAllSubMeshesAsTexturesDirty(): void;
  47807. /**
  47808. * Instantiate a new istance of clear coat configuration.
  47809. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47810. */
  47811. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47812. /**
  47813. * Gets wehter the submesh is ready to be used or not.
  47814. * @param defines the list of "defines" to update.
  47815. * @param scene defines the scene the material belongs to.
  47816. * @param engine defines the engine the material belongs to.
  47817. * @param disableBumpMap defines wether the material disables bump or not.
  47818. * @returns - boolean indicating that the submesh is ready or not.
  47819. */
  47820. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47821. /**
  47822. * Checks to see if a texture is used in the material.
  47823. * @param defines the list of "defines" to update.
  47824. * @param scene defines the scene to the material belongs to.
  47825. */
  47826. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47827. /**
  47828. * Binds the material data.
  47829. * @param uniformBuffer defines the Uniform buffer to fill in.
  47830. * @param scene defines the scene the material belongs to.
  47831. * @param engine defines the engine the material belongs to.
  47832. * @param disableBumpMap defines wether the material disables bump or not.
  47833. * @param isFrozen defines wether the material is frozen or not.
  47834. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47835. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47836. */
  47837. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47838. /**
  47839. * Checks to see if a texture is used in the material.
  47840. * @param texture - Base texture to use.
  47841. * @returns - Boolean specifying if a texture is used in the material.
  47842. */
  47843. hasTexture(texture: BaseTexture): boolean;
  47844. /**
  47845. * Returns an array of the actively used textures.
  47846. * @param activeTextures Array of BaseTextures
  47847. */
  47848. getActiveTextures(activeTextures: BaseTexture[]): void;
  47849. /**
  47850. * Returns the animatable textures.
  47851. * @param animatables Array of animatable textures.
  47852. */
  47853. getAnimatables(animatables: IAnimatable[]): void;
  47854. /**
  47855. * Disposes the resources of the material.
  47856. * @param forceDisposeTextures - Forces the disposal of all textures.
  47857. */
  47858. dispose(forceDisposeTextures?: boolean): void;
  47859. /**
  47860. * Get the current class name of the texture useful for serialization or dynamic coding.
  47861. * @returns "PBRClearCoatConfiguration"
  47862. */
  47863. getClassName(): string;
  47864. /**
  47865. * Add fallbacks to the effect fallbacks list.
  47866. * @param defines defines the Base texture to use.
  47867. * @param fallbacks defines the current fallback list.
  47868. * @param currentRank defines the current fallback rank.
  47869. * @returns the new fallback rank.
  47870. */
  47871. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47872. /**
  47873. * Add the required uniforms to the current list.
  47874. * @param uniforms defines the current uniform list.
  47875. */
  47876. static AddUniforms(uniforms: string[]): void;
  47877. /**
  47878. * Add the required samplers to the current list.
  47879. * @param samplers defines the current sampler list.
  47880. */
  47881. static AddSamplers(samplers: string[]): void;
  47882. /**
  47883. * Add the required uniforms to the current buffer.
  47884. * @param uniformBuffer defines the current uniform buffer.
  47885. */
  47886. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47887. /**
  47888. * Makes a duplicate of the current configuration into another one.
  47889. * @param clearCoatConfiguration define the config where to copy the info
  47890. */
  47891. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  47892. /**
  47893. * Serializes this clear coat configuration.
  47894. * @returns - An object with the serialized config.
  47895. */
  47896. serialize(): any;
  47897. /**
  47898. * Parses a anisotropy Configuration from a serialized object.
  47899. * @param source - Serialized object.
  47900. * @param scene Defines the scene we are parsing for
  47901. * @param rootUrl Defines the rootUrl to load from
  47902. */
  47903. parse(source: any, scene: Scene, rootUrl: string): void;
  47904. }
  47905. }
  47906. declare module BABYLON {
  47907. /**
  47908. * @hidden
  47909. */
  47910. export interface IMaterialAnisotropicDefines {
  47911. ANISOTROPIC: boolean;
  47912. ANISOTROPIC_TEXTURE: boolean;
  47913. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47914. MAINUV1: boolean;
  47915. _areTexturesDirty: boolean;
  47916. _needUVs: boolean;
  47917. }
  47918. /**
  47919. * Define the code related to the anisotropic parameters of the pbr material.
  47920. */
  47921. export class PBRAnisotropicConfiguration {
  47922. private _isEnabled;
  47923. /**
  47924. * Defines if the anisotropy is enabled in the material.
  47925. */
  47926. isEnabled: boolean;
  47927. /**
  47928. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  47929. */
  47930. intensity: number;
  47931. /**
  47932. * Defines if the effect is along the tangents, bitangents or in between.
  47933. * By default, the effect is "strectching" the highlights along the tangents.
  47934. */
  47935. direction: Vector2;
  47936. private _texture;
  47937. /**
  47938. * Stores the anisotropy values in a texture.
  47939. * rg is direction (like normal from -1 to 1)
  47940. * b is a intensity
  47941. */
  47942. texture: Nullable<BaseTexture>;
  47943. /** @hidden */
  47944. private _internalMarkAllSubMeshesAsTexturesDirty;
  47945. /** @hidden */
  47946. _markAllSubMeshesAsTexturesDirty(): void;
  47947. /**
  47948. * Instantiate a new istance of anisotropy configuration.
  47949. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47950. */
  47951. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47952. /**
  47953. * Specifies that the submesh is ready to be used.
  47954. * @param defines the list of "defines" to update.
  47955. * @param scene defines the scene the material belongs to.
  47956. * @returns - boolean indicating that the submesh is ready or not.
  47957. */
  47958. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47959. /**
  47960. * Checks to see if a texture is used in the material.
  47961. * @param defines the list of "defines" to update.
  47962. * @param mesh the mesh we are preparing the defines for.
  47963. * @param scene defines the scene the material belongs to.
  47964. */
  47965. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47966. /**
  47967. * Binds the material data.
  47968. * @param uniformBuffer defines the Uniform buffer to fill in.
  47969. * @param scene defines the scene the material belongs to.
  47970. * @param isFrozen defines wether the material is frozen or not.
  47971. */
  47972. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47973. /**
  47974. * Checks to see if a texture is used in the material.
  47975. * @param texture - Base texture to use.
  47976. * @returns - Boolean specifying if a texture is used in the material.
  47977. */
  47978. hasTexture(texture: BaseTexture): boolean;
  47979. /**
  47980. * Returns an array of the actively used textures.
  47981. * @param activeTextures Array of BaseTextures
  47982. */
  47983. getActiveTextures(activeTextures: BaseTexture[]): void;
  47984. /**
  47985. * Returns the animatable textures.
  47986. * @param animatables Array of animatable textures.
  47987. */
  47988. getAnimatables(animatables: IAnimatable[]): void;
  47989. /**
  47990. * Disposes the resources of the material.
  47991. * @param forceDisposeTextures - Forces the disposal of all textures.
  47992. */
  47993. dispose(forceDisposeTextures?: boolean): void;
  47994. /**
  47995. * Get the current class name of the texture useful for serialization or dynamic coding.
  47996. * @returns "PBRAnisotropicConfiguration"
  47997. */
  47998. getClassName(): string;
  47999. /**
  48000. * Add fallbacks to the effect fallbacks list.
  48001. * @param defines defines the Base texture to use.
  48002. * @param fallbacks defines the current fallback list.
  48003. * @param currentRank defines the current fallback rank.
  48004. * @returns the new fallback rank.
  48005. */
  48006. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48007. /**
  48008. * Add the required uniforms to the current list.
  48009. * @param uniforms defines the current uniform list.
  48010. */
  48011. static AddUniforms(uniforms: string[]): void;
  48012. /**
  48013. * Add the required uniforms to the current buffer.
  48014. * @param uniformBuffer defines the current uniform buffer.
  48015. */
  48016. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48017. /**
  48018. * Add the required samplers to the current list.
  48019. * @param samplers defines the current sampler list.
  48020. */
  48021. static AddSamplers(samplers: string[]): void;
  48022. /**
  48023. * Makes a duplicate of the current configuration into another one.
  48024. * @param anisotropicConfiguration define the config where to copy the info
  48025. */
  48026. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48027. /**
  48028. * Serializes this anisotropy configuration.
  48029. * @returns - An object with the serialized config.
  48030. */
  48031. serialize(): any;
  48032. /**
  48033. * Parses a anisotropy Configuration from a serialized object.
  48034. * @param source - Serialized object.
  48035. * @param scene Defines the scene we are parsing for
  48036. * @param rootUrl Defines the rootUrl to load from
  48037. */
  48038. parse(source: any, scene: Scene, rootUrl: string): void;
  48039. }
  48040. }
  48041. declare module BABYLON {
  48042. /**
  48043. * @hidden
  48044. */
  48045. export interface IMaterialBRDFDefines {
  48046. BRDF_V_HEIGHT_CORRELATED: boolean;
  48047. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48048. SPHERICAL_HARMONICS: boolean;
  48049. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48050. /** @hidden */
  48051. _areMiscDirty: boolean;
  48052. }
  48053. /**
  48054. * Define the code related to the BRDF parameters of the pbr material.
  48055. */
  48056. export class PBRBRDFConfiguration {
  48057. /**
  48058. * Default value used for the energy conservation.
  48059. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48060. */
  48061. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48062. /**
  48063. * Default value used for the Smith Visibility Height Correlated mode.
  48064. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48065. */
  48066. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48067. /**
  48068. * Default value used for the IBL diffuse part.
  48069. * This can help switching back to the polynomials mode globally which is a tiny bit
  48070. * less GPU intensive at the drawback of a lower quality.
  48071. */
  48072. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48073. /**
  48074. * Default value used for activating energy conservation for the specular workflow.
  48075. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48076. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48077. */
  48078. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48079. private _useEnergyConservation;
  48080. /**
  48081. * Defines if the material uses energy conservation.
  48082. */
  48083. useEnergyConservation: boolean;
  48084. private _useSmithVisibilityHeightCorrelated;
  48085. /**
  48086. * LEGACY Mode set to false
  48087. * Defines if the material uses height smith correlated visibility term.
  48088. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48089. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48090. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48091. * Not relying on height correlated will also disable energy conservation.
  48092. */
  48093. useSmithVisibilityHeightCorrelated: boolean;
  48094. private _useSphericalHarmonics;
  48095. /**
  48096. * LEGACY Mode set to false
  48097. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48098. * diffuse part of the IBL.
  48099. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48100. * to the ground truth.
  48101. */
  48102. useSphericalHarmonics: boolean;
  48103. private _useSpecularGlossinessInputEnergyConservation;
  48104. /**
  48105. * Defines if the material uses energy conservation, when the specular workflow is active.
  48106. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48107. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48108. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48109. */
  48110. useSpecularGlossinessInputEnergyConservation: boolean;
  48111. /** @hidden */
  48112. private _internalMarkAllSubMeshesAsMiscDirty;
  48113. /** @hidden */
  48114. _markAllSubMeshesAsMiscDirty(): void;
  48115. /**
  48116. * Instantiate a new istance of clear coat configuration.
  48117. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48118. */
  48119. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48120. /**
  48121. * Checks to see if a texture is used in the material.
  48122. * @param defines the list of "defines" to update.
  48123. */
  48124. prepareDefines(defines: IMaterialBRDFDefines): void;
  48125. /**
  48126. * Get the current class name of the texture useful for serialization or dynamic coding.
  48127. * @returns "PBRClearCoatConfiguration"
  48128. */
  48129. getClassName(): string;
  48130. /**
  48131. * Makes a duplicate of the current configuration into another one.
  48132. * @param brdfConfiguration define the config where to copy the info
  48133. */
  48134. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48135. /**
  48136. * Serializes this BRDF configuration.
  48137. * @returns - An object with the serialized config.
  48138. */
  48139. serialize(): any;
  48140. /**
  48141. * Parses a anisotropy Configuration from a serialized object.
  48142. * @param source - Serialized object.
  48143. * @param scene Defines the scene we are parsing for
  48144. * @param rootUrl Defines the rootUrl to load from
  48145. */
  48146. parse(source: any, scene: Scene, rootUrl: string): void;
  48147. }
  48148. }
  48149. declare module BABYLON {
  48150. /**
  48151. * @hidden
  48152. */
  48153. export interface IMaterialSheenDefines {
  48154. SHEEN: boolean;
  48155. SHEEN_TEXTURE: boolean;
  48156. SHEEN_TEXTUREDIRECTUV: number;
  48157. SHEEN_LINKWITHALBEDO: boolean;
  48158. /** @hidden */
  48159. _areTexturesDirty: boolean;
  48160. }
  48161. /**
  48162. * Define the code related to the Sheen parameters of the pbr material.
  48163. */
  48164. export class PBRSheenConfiguration {
  48165. private _isEnabled;
  48166. /**
  48167. * Defines if the material uses sheen.
  48168. */
  48169. isEnabled: boolean;
  48170. private _linkSheenWithAlbedo;
  48171. /**
  48172. * Defines if the sheen is linked to the sheen color.
  48173. */
  48174. linkSheenWithAlbedo: boolean;
  48175. /**
  48176. * Defines the sheen intensity.
  48177. */
  48178. intensity: number;
  48179. /**
  48180. * Defines the sheen color.
  48181. */
  48182. color: Color3;
  48183. private _texture;
  48184. /**
  48185. * Stores the sheen tint values in a texture.
  48186. * rgb is tint
  48187. * a is a intensity
  48188. */
  48189. texture: Nullable<BaseTexture>;
  48190. /** @hidden */
  48191. private _internalMarkAllSubMeshesAsTexturesDirty;
  48192. /** @hidden */
  48193. _markAllSubMeshesAsTexturesDirty(): void;
  48194. /**
  48195. * Instantiate a new istance of clear coat configuration.
  48196. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48197. */
  48198. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48199. /**
  48200. * Specifies that the submesh is ready to be used.
  48201. * @param defines the list of "defines" to update.
  48202. * @param scene defines the scene the material belongs to.
  48203. * @returns - boolean indicating that the submesh is ready or not.
  48204. */
  48205. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48206. /**
  48207. * Checks to see if a texture is used in the material.
  48208. * @param defines the list of "defines" to update.
  48209. * @param scene defines the scene the material belongs to.
  48210. */
  48211. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48212. /**
  48213. * Binds the material data.
  48214. * @param uniformBuffer defines the Uniform buffer to fill in.
  48215. * @param scene defines the scene the material belongs to.
  48216. * @param isFrozen defines wether the material is frozen or not.
  48217. */
  48218. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48219. /**
  48220. * Checks to see if a texture is used in the material.
  48221. * @param texture - Base texture to use.
  48222. * @returns - Boolean specifying if a texture is used in the material.
  48223. */
  48224. hasTexture(texture: BaseTexture): boolean;
  48225. /**
  48226. * Returns an array of the actively used textures.
  48227. * @param activeTextures Array of BaseTextures
  48228. */
  48229. getActiveTextures(activeTextures: BaseTexture[]): void;
  48230. /**
  48231. * Returns the animatable textures.
  48232. * @param animatables Array of animatable textures.
  48233. */
  48234. getAnimatables(animatables: IAnimatable[]): void;
  48235. /**
  48236. * Disposes the resources of the material.
  48237. * @param forceDisposeTextures - Forces the disposal of all textures.
  48238. */
  48239. dispose(forceDisposeTextures?: boolean): void;
  48240. /**
  48241. * Get the current class name of the texture useful for serialization or dynamic coding.
  48242. * @returns "PBRSheenConfiguration"
  48243. */
  48244. getClassName(): string;
  48245. /**
  48246. * Add fallbacks to the effect fallbacks list.
  48247. * @param defines defines the Base texture to use.
  48248. * @param fallbacks defines the current fallback list.
  48249. * @param currentRank defines the current fallback rank.
  48250. * @returns the new fallback rank.
  48251. */
  48252. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48253. /**
  48254. * Add the required uniforms to the current list.
  48255. * @param uniforms defines the current uniform list.
  48256. */
  48257. static AddUniforms(uniforms: string[]): void;
  48258. /**
  48259. * Add the required uniforms to the current buffer.
  48260. * @param uniformBuffer defines the current uniform buffer.
  48261. */
  48262. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48263. /**
  48264. * Add the required samplers to the current list.
  48265. * @param samplers defines the current sampler list.
  48266. */
  48267. static AddSamplers(samplers: string[]): void;
  48268. /**
  48269. * Makes a duplicate of the current configuration into another one.
  48270. * @param sheenConfiguration define the config where to copy the info
  48271. */
  48272. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48273. /**
  48274. * Serializes this BRDF configuration.
  48275. * @returns - An object with the serialized config.
  48276. */
  48277. serialize(): any;
  48278. /**
  48279. * Parses a anisotropy Configuration from a serialized object.
  48280. * @param source - Serialized object.
  48281. * @param scene Defines the scene we are parsing for
  48282. * @param rootUrl Defines the rootUrl to load from
  48283. */
  48284. parse(source: any, scene: Scene, rootUrl: string): void;
  48285. }
  48286. }
  48287. declare module BABYLON {
  48288. /**
  48289. * @hidden
  48290. */
  48291. export interface IMaterialSubSurfaceDefines {
  48292. SUBSURFACE: boolean;
  48293. SS_REFRACTION: boolean;
  48294. SS_TRANSLUCENCY: boolean;
  48295. SS_SCATERRING: boolean;
  48296. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48297. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48298. SS_REFRACTIONMAP_3D: boolean;
  48299. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48300. SS_LODINREFRACTIONALPHA: boolean;
  48301. SS_GAMMAREFRACTION: boolean;
  48302. SS_RGBDREFRACTION: boolean;
  48303. SS_LINEARSPECULARREFRACTION: boolean;
  48304. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48305. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48306. /** @hidden */
  48307. _areTexturesDirty: boolean;
  48308. }
  48309. /**
  48310. * Define the code related to the sub surface parameters of the pbr material.
  48311. */
  48312. export class PBRSubSurfaceConfiguration {
  48313. private _isRefractionEnabled;
  48314. /**
  48315. * Defines if the refraction is enabled in the material.
  48316. */
  48317. isRefractionEnabled: boolean;
  48318. private _isTranslucencyEnabled;
  48319. /**
  48320. * Defines if the translucency is enabled in the material.
  48321. */
  48322. isTranslucencyEnabled: boolean;
  48323. private _isScatteringEnabled;
  48324. /**
  48325. * Defines the refraction intensity of the material.
  48326. * The refraction when enabled replaces the Diffuse part of the material.
  48327. * The intensity helps transitionning between diffuse and refraction.
  48328. */
  48329. refractionIntensity: number;
  48330. /**
  48331. * Defines the translucency intensity of the material.
  48332. * When translucency has been enabled, this defines how much of the "translucency"
  48333. * is addded to the diffuse part of the material.
  48334. */
  48335. translucencyIntensity: number;
  48336. /**
  48337. * Defines the scattering intensity of the material.
  48338. * When scattering has been enabled, this defines how much of the "scattered light"
  48339. * is addded to the diffuse part of the material.
  48340. */
  48341. scatteringIntensity: number;
  48342. private _thicknessTexture;
  48343. /**
  48344. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  48345. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  48346. * 0 would mean minimumThickness
  48347. * 1 would mean maximumThickness
  48348. * The other channels might be use as a mask to vary the different effects intensity.
  48349. */
  48350. thicknessTexture: Nullable<BaseTexture>;
  48351. private _refractionTexture;
  48352. /**
  48353. * Defines the texture to use for refraction.
  48354. */
  48355. refractionTexture: Nullable<BaseTexture>;
  48356. private _indexOfRefraction;
  48357. /**
  48358. * Defines the index of refraction used in the material.
  48359. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  48360. */
  48361. indexOfRefraction: number;
  48362. private _invertRefractionY;
  48363. /**
  48364. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48365. */
  48366. invertRefractionY: boolean;
  48367. private _linkRefractionWithTransparency;
  48368. /**
  48369. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48370. * Materials half opaque for instance using refraction could benefit from this control.
  48371. */
  48372. linkRefractionWithTransparency: boolean;
  48373. /**
  48374. * Defines the minimum thickness stored in the thickness map.
  48375. * If no thickness map is defined, this value will be used to simulate thickness.
  48376. */
  48377. minimumThickness: number;
  48378. /**
  48379. * Defines the maximum thickness stored in the thickness map.
  48380. */
  48381. maximumThickness: number;
  48382. /**
  48383. * Defines the volume tint of the material.
  48384. * This is used for both translucency and scattering.
  48385. */
  48386. tintColor: Color3;
  48387. /**
  48388. * Defines the distance at which the tint color should be found in the media.
  48389. * This is used for refraction only.
  48390. */
  48391. tintColorAtDistance: number;
  48392. /**
  48393. * Defines how far each channel transmit through the media.
  48394. * It is defined as a color to simplify it selection.
  48395. */
  48396. diffusionDistance: Color3;
  48397. private _useMaskFromThicknessTexture;
  48398. /**
  48399. * Stores the intensity of the different subsurface effects in the thickness texture.
  48400. * * the green channel is the translucency intensity.
  48401. * * the blue channel is the scattering intensity.
  48402. * * the alpha channel is the refraction intensity.
  48403. */
  48404. useMaskFromThicknessTexture: boolean;
  48405. /** @hidden */
  48406. private _internalMarkAllSubMeshesAsTexturesDirty;
  48407. /** @hidden */
  48408. _markAllSubMeshesAsTexturesDirty(): void;
  48409. /**
  48410. * Instantiate a new istance of sub surface configuration.
  48411. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48412. */
  48413. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48414. /**
  48415. * Gets wehter the submesh is ready to be used or not.
  48416. * @param defines the list of "defines" to update.
  48417. * @param scene defines the scene the material belongs to.
  48418. * @returns - boolean indicating that the submesh is ready or not.
  48419. */
  48420. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  48421. /**
  48422. * Checks to see if a texture is used in the material.
  48423. * @param defines the list of "defines" to update.
  48424. * @param scene defines the scene to the material belongs to.
  48425. */
  48426. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  48427. /**
  48428. * Binds the material data.
  48429. * @param uniformBuffer defines the Uniform buffer to fill in.
  48430. * @param scene defines the scene the material belongs to.
  48431. * @param engine defines the engine the material belongs to.
  48432. * @param isFrozen defines wether the material is frozen or not.
  48433. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  48434. */
  48435. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  48436. /**
  48437. * Unbinds the material from the mesh.
  48438. * @param activeEffect defines the effect that should be unbound from.
  48439. * @returns true if unbound, otherwise false
  48440. */
  48441. unbind(activeEffect: Effect): boolean;
  48442. /**
  48443. * Returns the texture used for refraction or null if none is used.
  48444. * @param scene defines the scene the material belongs to.
  48445. * @returns - Refraction texture if present. If no refraction texture and refraction
  48446. * is linked with transparency, returns environment texture. Otherwise, returns null.
  48447. */
  48448. private _getRefractionTexture;
  48449. /**
  48450. * Returns true if alpha blending should be disabled.
  48451. */
  48452. readonly disableAlphaBlending: boolean;
  48453. /**
  48454. * Fills the list of render target textures.
  48455. * @param renderTargets the list of render targets to update
  48456. */
  48457. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48458. /**
  48459. * Checks to see if a texture is used in the material.
  48460. * @param texture - Base texture to use.
  48461. * @returns - Boolean specifying if a texture is used in the material.
  48462. */
  48463. hasTexture(texture: BaseTexture): boolean;
  48464. /**
  48465. * Gets a boolean indicating that current material needs to register RTT
  48466. * @returns true if this uses a render target otherwise false.
  48467. */
  48468. hasRenderTargetTextures(): boolean;
  48469. /**
  48470. * Returns an array of the actively used textures.
  48471. * @param activeTextures Array of BaseTextures
  48472. */
  48473. getActiveTextures(activeTextures: BaseTexture[]): void;
  48474. /**
  48475. * Returns the animatable textures.
  48476. * @param animatables Array of animatable textures.
  48477. */
  48478. getAnimatables(animatables: IAnimatable[]): void;
  48479. /**
  48480. * Disposes the resources of the material.
  48481. * @param forceDisposeTextures - Forces the disposal of all textures.
  48482. */
  48483. dispose(forceDisposeTextures?: boolean): void;
  48484. /**
  48485. * Get the current class name of the texture useful for serialization or dynamic coding.
  48486. * @returns "PBRSubSurfaceConfiguration"
  48487. */
  48488. getClassName(): string;
  48489. /**
  48490. * Add fallbacks to the effect fallbacks list.
  48491. * @param defines defines the Base texture to use.
  48492. * @param fallbacks defines the current fallback list.
  48493. * @param currentRank defines the current fallback rank.
  48494. * @returns the new fallback rank.
  48495. */
  48496. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48497. /**
  48498. * Add the required uniforms to the current list.
  48499. * @param uniforms defines the current uniform list.
  48500. */
  48501. static AddUniforms(uniforms: string[]): void;
  48502. /**
  48503. * Add the required samplers to the current list.
  48504. * @param samplers defines the current sampler list.
  48505. */
  48506. static AddSamplers(samplers: string[]): void;
  48507. /**
  48508. * Add the required uniforms to the current buffer.
  48509. * @param uniformBuffer defines the current uniform buffer.
  48510. */
  48511. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48512. /**
  48513. * Makes a duplicate of the current configuration into another one.
  48514. * @param configuration define the config where to copy the info
  48515. */
  48516. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48517. /**
  48518. * Serializes this Sub Surface configuration.
  48519. * @returns - An object with the serialized config.
  48520. */
  48521. serialize(): any;
  48522. /**
  48523. * Parses a anisotropy Configuration from a serialized object.
  48524. * @param source - Serialized object.
  48525. * @param scene Defines the scene we are parsing for
  48526. * @param rootUrl Defines the rootUrl to load from
  48527. */
  48528. parse(source: any, scene: Scene, rootUrl: string): void;
  48529. }
  48530. }
  48531. declare module BABYLON {
  48532. /** @hidden */
  48533. export var pbrFragmentDeclaration: {
  48534. name: string;
  48535. shader: string;
  48536. };
  48537. }
  48538. declare module BABYLON {
  48539. /** @hidden */
  48540. export var pbrUboDeclaration: {
  48541. name: string;
  48542. shader: string;
  48543. };
  48544. }
  48545. declare module BABYLON {
  48546. /** @hidden */
  48547. export var pbrFragmentExtraDeclaration: {
  48548. name: string;
  48549. shader: string;
  48550. };
  48551. }
  48552. declare module BABYLON {
  48553. /** @hidden */
  48554. export var pbrFragmentSamplersDeclaration: {
  48555. name: string;
  48556. shader: string;
  48557. };
  48558. }
  48559. declare module BABYLON {
  48560. /** @hidden */
  48561. export var pbrHelperFunctions: {
  48562. name: string;
  48563. shader: string;
  48564. };
  48565. }
  48566. declare module BABYLON {
  48567. /** @hidden */
  48568. export var harmonicsFunctions: {
  48569. name: string;
  48570. shader: string;
  48571. };
  48572. }
  48573. declare module BABYLON {
  48574. /** @hidden */
  48575. export var pbrDirectLightingSetupFunctions: {
  48576. name: string;
  48577. shader: string;
  48578. };
  48579. }
  48580. declare module BABYLON {
  48581. /** @hidden */
  48582. export var pbrDirectLightingFalloffFunctions: {
  48583. name: string;
  48584. shader: string;
  48585. };
  48586. }
  48587. declare module BABYLON {
  48588. /** @hidden */
  48589. export var pbrBRDFFunctions: {
  48590. name: string;
  48591. shader: string;
  48592. };
  48593. }
  48594. declare module BABYLON {
  48595. /** @hidden */
  48596. export var pbrDirectLightingFunctions: {
  48597. name: string;
  48598. shader: string;
  48599. };
  48600. }
  48601. declare module BABYLON {
  48602. /** @hidden */
  48603. export var pbrIBLFunctions: {
  48604. name: string;
  48605. shader: string;
  48606. };
  48607. }
  48608. declare module BABYLON {
  48609. /** @hidden */
  48610. export var pbrDebug: {
  48611. name: string;
  48612. shader: string;
  48613. };
  48614. }
  48615. declare module BABYLON {
  48616. /** @hidden */
  48617. export var pbrPixelShader: {
  48618. name: string;
  48619. shader: string;
  48620. };
  48621. }
  48622. declare module BABYLON {
  48623. /** @hidden */
  48624. export var pbrVertexDeclaration: {
  48625. name: string;
  48626. shader: string;
  48627. };
  48628. }
  48629. declare module BABYLON {
  48630. /** @hidden */
  48631. export var pbrVertexShader: {
  48632. name: string;
  48633. shader: string;
  48634. };
  48635. }
  48636. declare module BABYLON {
  48637. /**
  48638. * Manages the defines for the PBR Material.
  48639. * @hidden
  48640. */
  48641. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48642. PBR: boolean;
  48643. MAINUV1: boolean;
  48644. MAINUV2: boolean;
  48645. UV1: boolean;
  48646. UV2: boolean;
  48647. ALBEDO: boolean;
  48648. ALBEDODIRECTUV: number;
  48649. VERTEXCOLOR: boolean;
  48650. AMBIENT: boolean;
  48651. AMBIENTDIRECTUV: number;
  48652. AMBIENTINGRAYSCALE: boolean;
  48653. OPACITY: boolean;
  48654. VERTEXALPHA: boolean;
  48655. OPACITYDIRECTUV: number;
  48656. OPACITYRGB: boolean;
  48657. ALPHATEST: boolean;
  48658. DEPTHPREPASS: boolean;
  48659. ALPHABLEND: boolean;
  48660. ALPHAFROMALBEDO: boolean;
  48661. ALPHATESTVALUE: string;
  48662. SPECULAROVERALPHA: boolean;
  48663. RADIANCEOVERALPHA: boolean;
  48664. ALPHAFRESNEL: boolean;
  48665. LINEARALPHAFRESNEL: boolean;
  48666. PREMULTIPLYALPHA: boolean;
  48667. EMISSIVE: boolean;
  48668. EMISSIVEDIRECTUV: number;
  48669. REFLECTIVITY: boolean;
  48670. REFLECTIVITYDIRECTUV: number;
  48671. SPECULARTERM: boolean;
  48672. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48673. MICROSURFACEAUTOMATIC: boolean;
  48674. LODBASEDMICROSFURACE: boolean;
  48675. MICROSURFACEMAP: boolean;
  48676. MICROSURFACEMAPDIRECTUV: number;
  48677. METALLICWORKFLOW: boolean;
  48678. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48679. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48680. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48681. AOSTOREINMETALMAPRED: boolean;
  48682. METALLICF0FACTORFROMMETALLICMAP: boolean;
  48683. ENVIRONMENTBRDF: boolean;
  48684. ENVIRONMENTBRDF_RGBD: boolean;
  48685. NORMAL: boolean;
  48686. TANGENT: boolean;
  48687. BUMP: boolean;
  48688. BUMPDIRECTUV: number;
  48689. OBJECTSPACE_NORMALMAP: boolean;
  48690. PARALLAX: boolean;
  48691. PARALLAXOCCLUSION: boolean;
  48692. NORMALXYSCALE: boolean;
  48693. LIGHTMAP: boolean;
  48694. LIGHTMAPDIRECTUV: number;
  48695. USELIGHTMAPASSHADOWMAP: boolean;
  48696. GAMMALIGHTMAP: boolean;
  48697. RGBDLIGHTMAP: boolean;
  48698. REFLECTION: boolean;
  48699. REFLECTIONMAP_3D: boolean;
  48700. REFLECTIONMAP_SPHERICAL: boolean;
  48701. REFLECTIONMAP_PLANAR: boolean;
  48702. REFLECTIONMAP_CUBIC: boolean;
  48703. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48704. REFLECTIONMAP_PROJECTION: boolean;
  48705. REFLECTIONMAP_SKYBOX: boolean;
  48706. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48707. REFLECTIONMAP_EXPLICIT: boolean;
  48708. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48709. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48710. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48711. INVERTCUBICMAP: boolean;
  48712. USESPHERICALFROMREFLECTIONMAP: boolean;
  48713. USEIRRADIANCEMAP: boolean;
  48714. SPHERICAL_HARMONICS: boolean;
  48715. USESPHERICALINVERTEX: boolean;
  48716. REFLECTIONMAP_OPPOSITEZ: boolean;
  48717. LODINREFLECTIONALPHA: boolean;
  48718. GAMMAREFLECTION: boolean;
  48719. RGBDREFLECTION: boolean;
  48720. LINEARSPECULARREFLECTION: boolean;
  48721. RADIANCEOCCLUSION: boolean;
  48722. HORIZONOCCLUSION: boolean;
  48723. INSTANCES: boolean;
  48724. NUM_BONE_INFLUENCERS: number;
  48725. BonesPerMesh: number;
  48726. BONETEXTURE: boolean;
  48727. NONUNIFORMSCALING: boolean;
  48728. MORPHTARGETS: boolean;
  48729. MORPHTARGETS_NORMAL: boolean;
  48730. MORPHTARGETS_TANGENT: boolean;
  48731. MORPHTARGETS_UV: boolean;
  48732. NUM_MORPH_INFLUENCERS: number;
  48733. IMAGEPROCESSING: boolean;
  48734. VIGNETTE: boolean;
  48735. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48736. VIGNETTEBLENDMODEOPAQUE: boolean;
  48737. TONEMAPPING: boolean;
  48738. TONEMAPPING_ACES: boolean;
  48739. CONTRAST: boolean;
  48740. COLORCURVES: boolean;
  48741. COLORGRADING: boolean;
  48742. COLORGRADING3D: boolean;
  48743. SAMPLER3DGREENDEPTH: boolean;
  48744. SAMPLER3DBGRMAP: boolean;
  48745. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48746. EXPOSURE: boolean;
  48747. MULTIVIEW: boolean;
  48748. USEPHYSICALLIGHTFALLOFF: boolean;
  48749. USEGLTFLIGHTFALLOFF: boolean;
  48750. TWOSIDEDLIGHTING: boolean;
  48751. SHADOWFLOAT: boolean;
  48752. CLIPPLANE: boolean;
  48753. CLIPPLANE2: boolean;
  48754. CLIPPLANE3: boolean;
  48755. CLIPPLANE4: boolean;
  48756. POINTSIZE: boolean;
  48757. FOG: boolean;
  48758. LOGARITHMICDEPTH: boolean;
  48759. FORCENORMALFORWARD: boolean;
  48760. SPECULARAA: boolean;
  48761. CLEARCOAT: boolean;
  48762. CLEARCOAT_DEFAULTIOR: boolean;
  48763. CLEARCOAT_TEXTURE: boolean;
  48764. CLEARCOAT_TEXTUREDIRECTUV: number;
  48765. CLEARCOAT_BUMP: boolean;
  48766. CLEARCOAT_BUMPDIRECTUV: number;
  48767. CLEARCOAT_TINT: boolean;
  48768. CLEARCOAT_TINT_TEXTURE: boolean;
  48769. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48770. ANISOTROPIC: boolean;
  48771. ANISOTROPIC_TEXTURE: boolean;
  48772. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48773. BRDF_V_HEIGHT_CORRELATED: boolean;
  48774. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48775. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48776. SHEEN: boolean;
  48777. SHEEN_TEXTURE: boolean;
  48778. SHEEN_TEXTUREDIRECTUV: number;
  48779. SHEEN_LINKWITHALBEDO: boolean;
  48780. SUBSURFACE: boolean;
  48781. SS_REFRACTION: boolean;
  48782. SS_TRANSLUCENCY: boolean;
  48783. SS_SCATERRING: boolean;
  48784. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48785. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48786. SS_REFRACTIONMAP_3D: boolean;
  48787. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48788. SS_LODINREFRACTIONALPHA: boolean;
  48789. SS_GAMMAREFRACTION: boolean;
  48790. SS_RGBDREFRACTION: boolean;
  48791. SS_LINEARSPECULARREFRACTION: boolean;
  48792. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48793. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48794. UNLIT: boolean;
  48795. DEBUGMODE: number;
  48796. /**
  48797. * Initializes the PBR Material defines.
  48798. */
  48799. constructor();
  48800. /**
  48801. * Resets the PBR Material defines.
  48802. */
  48803. reset(): void;
  48804. }
  48805. /**
  48806. * The Physically based material base class of BJS.
  48807. *
  48808. * This offers the main features of a standard PBR material.
  48809. * For more information, please refer to the documentation :
  48810. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48811. */
  48812. export abstract class PBRBaseMaterial extends PushMaterial {
  48813. /**
  48814. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48815. */
  48816. static readonly PBRMATERIAL_OPAQUE: number;
  48817. /**
  48818. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48819. */
  48820. static readonly PBRMATERIAL_ALPHATEST: number;
  48821. /**
  48822. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48823. */
  48824. static readonly PBRMATERIAL_ALPHABLEND: number;
  48825. /**
  48826. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48827. * They are also discarded below the alpha cutoff threshold to improve performances.
  48828. */
  48829. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48830. /**
  48831. * Defines the default value of how much AO map is occluding the analytical lights
  48832. * (point spot...).
  48833. */
  48834. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48835. /**
  48836. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  48837. */
  48838. static readonly LIGHTFALLOFF_PHYSICAL: number;
  48839. /**
  48840. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  48841. * to enhance interoperability with other engines.
  48842. */
  48843. static readonly LIGHTFALLOFF_GLTF: number;
  48844. /**
  48845. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  48846. * to enhance interoperability with other materials.
  48847. */
  48848. static readonly LIGHTFALLOFF_STANDARD: number;
  48849. /**
  48850. * Intensity of the direct lights e.g. the four lights available in your scene.
  48851. * This impacts both the direct diffuse and specular highlights.
  48852. */
  48853. protected _directIntensity: number;
  48854. /**
  48855. * Intensity of the emissive part of the material.
  48856. * This helps controlling the emissive effect without modifying the emissive color.
  48857. */
  48858. protected _emissiveIntensity: number;
  48859. /**
  48860. * Intensity of the environment e.g. how much the environment will light the object
  48861. * either through harmonics for rough material or through the refelction for shiny ones.
  48862. */
  48863. protected _environmentIntensity: number;
  48864. /**
  48865. * This is a special control allowing the reduction of the specular highlights coming from the
  48866. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48867. */
  48868. protected _specularIntensity: number;
  48869. /**
  48870. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  48871. */
  48872. private _lightingInfos;
  48873. /**
  48874. * Debug Control allowing disabling the bump map on this material.
  48875. */
  48876. protected _disableBumpMap: boolean;
  48877. /**
  48878. * AKA Diffuse Texture in standard nomenclature.
  48879. */
  48880. protected _albedoTexture: Nullable<BaseTexture>;
  48881. /**
  48882. * AKA Occlusion Texture in other nomenclature.
  48883. */
  48884. protected _ambientTexture: Nullable<BaseTexture>;
  48885. /**
  48886. * AKA Occlusion Texture Intensity in other nomenclature.
  48887. */
  48888. protected _ambientTextureStrength: number;
  48889. /**
  48890. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48891. * 1 means it completely occludes it
  48892. * 0 mean it has no impact
  48893. */
  48894. protected _ambientTextureImpactOnAnalyticalLights: number;
  48895. /**
  48896. * Stores the alpha values in a texture.
  48897. */
  48898. protected _opacityTexture: Nullable<BaseTexture>;
  48899. /**
  48900. * Stores the reflection values in a texture.
  48901. */
  48902. protected _reflectionTexture: Nullable<BaseTexture>;
  48903. /**
  48904. * Stores the emissive values in a texture.
  48905. */
  48906. protected _emissiveTexture: Nullable<BaseTexture>;
  48907. /**
  48908. * AKA Specular texture in other nomenclature.
  48909. */
  48910. protected _reflectivityTexture: Nullable<BaseTexture>;
  48911. /**
  48912. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48913. */
  48914. protected _metallicTexture: Nullable<BaseTexture>;
  48915. /**
  48916. * Specifies the metallic scalar of the metallic/roughness workflow.
  48917. * Can also be used to scale the metalness values of the metallic texture.
  48918. */
  48919. protected _metallic: Nullable<number>;
  48920. /**
  48921. * Specifies the roughness scalar of the metallic/roughness workflow.
  48922. * Can also be used to scale the roughness values of the metallic texture.
  48923. */
  48924. protected _roughness: Nullable<number>;
  48925. /**
  48926. * Specifies the an F0 factor to help configuring the material F0.
  48927. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  48928. * to 0.5 the previously hard coded value stays the same.
  48929. * Can also be used to scale the F0 values of the metallic texture.
  48930. */
  48931. protected _metallicF0Factor: number;
  48932. /**
  48933. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  48934. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  48935. * your expectation as it multiplies with the texture data.
  48936. */
  48937. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  48938. /**
  48939. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48940. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48941. */
  48942. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48943. /**
  48944. * Stores surface normal data used to displace a mesh in a texture.
  48945. */
  48946. protected _bumpTexture: Nullable<BaseTexture>;
  48947. /**
  48948. * Stores the pre-calculated light information of a mesh in a texture.
  48949. */
  48950. protected _lightmapTexture: Nullable<BaseTexture>;
  48951. /**
  48952. * The color of a material in ambient lighting.
  48953. */
  48954. protected _ambientColor: Color3;
  48955. /**
  48956. * AKA Diffuse Color in other nomenclature.
  48957. */
  48958. protected _albedoColor: Color3;
  48959. /**
  48960. * AKA Specular Color in other nomenclature.
  48961. */
  48962. protected _reflectivityColor: Color3;
  48963. /**
  48964. * The color applied when light is reflected from a material.
  48965. */
  48966. protected _reflectionColor: Color3;
  48967. /**
  48968. * The color applied when light is emitted from a material.
  48969. */
  48970. protected _emissiveColor: Color3;
  48971. /**
  48972. * AKA Glossiness in other nomenclature.
  48973. */
  48974. protected _microSurface: number;
  48975. /**
  48976. * Specifies that the material will use the light map as a show map.
  48977. */
  48978. protected _useLightmapAsShadowmap: boolean;
  48979. /**
  48980. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48981. * makes the reflect vector face the model (under horizon).
  48982. */
  48983. protected _useHorizonOcclusion: boolean;
  48984. /**
  48985. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48986. * too much the area relying on ambient texture to define their ambient occlusion.
  48987. */
  48988. protected _useRadianceOcclusion: boolean;
  48989. /**
  48990. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48991. */
  48992. protected _useAlphaFromAlbedoTexture: boolean;
  48993. /**
  48994. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  48995. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48996. */
  48997. protected _useSpecularOverAlpha: boolean;
  48998. /**
  48999. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49000. */
  49001. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49002. /**
  49003. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49004. */
  49005. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49006. /**
  49007. * Specifies if the metallic texture contains the roughness information in its green channel.
  49008. */
  49009. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49010. /**
  49011. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49012. */
  49013. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49014. /**
  49015. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49016. */
  49017. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49018. /**
  49019. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49020. */
  49021. protected _useAmbientInGrayScale: boolean;
  49022. /**
  49023. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49024. * The material will try to infer what glossiness each pixel should be.
  49025. */
  49026. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49027. /**
  49028. * Defines the falloff type used in this material.
  49029. * It by default is Physical.
  49030. */
  49031. protected _lightFalloff: number;
  49032. /**
  49033. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49034. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49035. */
  49036. protected _useRadianceOverAlpha: boolean;
  49037. /**
  49038. * Allows using an object space normal map (instead of tangent space).
  49039. */
  49040. protected _useObjectSpaceNormalMap: boolean;
  49041. /**
  49042. * Allows using the bump map in parallax mode.
  49043. */
  49044. protected _useParallax: boolean;
  49045. /**
  49046. * Allows using the bump map in parallax occlusion mode.
  49047. */
  49048. protected _useParallaxOcclusion: boolean;
  49049. /**
  49050. * Controls the scale bias of the parallax mode.
  49051. */
  49052. protected _parallaxScaleBias: number;
  49053. /**
  49054. * If sets to true, disables all the lights affecting the material.
  49055. */
  49056. protected _disableLighting: boolean;
  49057. /**
  49058. * Number of Simultaneous lights allowed on the material.
  49059. */
  49060. protected _maxSimultaneousLights: number;
  49061. /**
  49062. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49063. */
  49064. protected _invertNormalMapX: boolean;
  49065. /**
  49066. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49067. */
  49068. protected _invertNormalMapY: boolean;
  49069. /**
  49070. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49071. */
  49072. protected _twoSidedLighting: boolean;
  49073. /**
  49074. * Defines the alpha limits in alpha test mode.
  49075. */
  49076. protected _alphaCutOff: number;
  49077. /**
  49078. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49079. */
  49080. protected _forceAlphaTest: boolean;
  49081. /**
  49082. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49083. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49084. */
  49085. protected _useAlphaFresnel: boolean;
  49086. /**
  49087. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49088. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49089. */
  49090. protected _useLinearAlphaFresnel: boolean;
  49091. /**
  49092. * The transparency mode of the material.
  49093. */
  49094. protected _transparencyMode: Nullable<number>;
  49095. /**
  49096. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49097. * from cos thetav and roughness:
  49098. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49099. */
  49100. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49101. /**
  49102. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49103. */
  49104. protected _forceIrradianceInFragment: boolean;
  49105. /**
  49106. * Force normal to face away from face.
  49107. */
  49108. protected _forceNormalForward: boolean;
  49109. /**
  49110. * Enables specular anti aliasing in the PBR shader.
  49111. * It will both interacts on the Geometry for analytical and IBL lighting.
  49112. * It also prefilter the roughness map based on the bump values.
  49113. */
  49114. protected _enableSpecularAntiAliasing: boolean;
  49115. /**
  49116. * Default configuration related to image processing available in the PBR Material.
  49117. */
  49118. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49119. /**
  49120. * Keep track of the image processing observer to allow dispose and replace.
  49121. */
  49122. private _imageProcessingObserver;
  49123. /**
  49124. * Attaches a new image processing configuration to the PBR Material.
  49125. * @param configuration
  49126. */
  49127. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49128. /**
  49129. * Stores the available render targets.
  49130. */
  49131. private _renderTargets;
  49132. /**
  49133. * Sets the global ambient color for the material used in lighting calculations.
  49134. */
  49135. private _globalAmbientColor;
  49136. /**
  49137. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49138. */
  49139. private _useLogarithmicDepth;
  49140. /**
  49141. * If set to true, no lighting calculations will be applied.
  49142. */
  49143. private _unlit;
  49144. private _debugMode;
  49145. /**
  49146. * @hidden
  49147. * This is reserved for the inspector.
  49148. * Defines the material debug mode.
  49149. * It helps seeing only some components of the material while troubleshooting.
  49150. */
  49151. debugMode: number;
  49152. /**
  49153. * @hidden
  49154. * This is reserved for the inspector.
  49155. * Specify from where on screen the debug mode should start.
  49156. * The value goes from -1 (full screen) to 1 (not visible)
  49157. * It helps with side by side comparison against the final render
  49158. * This defaults to -1
  49159. */
  49160. private debugLimit;
  49161. /**
  49162. * @hidden
  49163. * This is reserved for the inspector.
  49164. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49165. * You can use the factor to better multiply the final value.
  49166. */
  49167. private debugFactor;
  49168. /**
  49169. * Defines the clear coat layer parameters for the material.
  49170. */
  49171. readonly clearCoat: PBRClearCoatConfiguration;
  49172. /**
  49173. * Defines the anisotropic parameters for the material.
  49174. */
  49175. readonly anisotropy: PBRAnisotropicConfiguration;
  49176. /**
  49177. * Defines the BRDF parameters for the material.
  49178. */
  49179. readonly brdf: PBRBRDFConfiguration;
  49180. /**
  49181. * Defines the Sheen parameters for the material.
  49182. */
  49183. readonly sheen: PBRSheenConfiguration;
  49184. /**
  49185. * Defines the SubSurface parameters for the material.
  49186. */
  49187. readonly subSurface: PBRSubSurfaceConfiguration;
  49188. /**
  49189. * Custom callback helping to override the default shader used in the material.
  49190. */
  49191. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49192. protected _rebuildInParallel: boolean;
  49193. /**
  49194. * Instantiates a new PBRMaterial instance.
  49195. *
  49196. * @param name The material name
  49197. * @param scene The scene the material will be use in.
  49198. */
  49199. constructor(name: string, scene: Scene);
  49200. /**
  49201. * Gets a boolean indicating that current material needs to register RTT
  49202. */
  49203. readonly hasRenderTargetTextures: boolean;
  49204. /**
  49205. * Gets the name of the material class.
  49206. */
  49207. getClassName(): string;
  49208. /**
  49209. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49210. */
  49211. /**
  49212. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49213. */
  49214. useLogarithmicDepth: boolean;
  49215. /**
  49216. * Gets the current transparency mode.
  49217. */
  49218. /**
  49219. * Sets the transparency mode of the material.
  49220. *
  49221. * | Value | Type | Description |
  49222. * | ----- | ----------------------------------- | ----------- |
  49223. * | 0 | OPAQUE | |
  49224. * | 1 | ALPHATEST | |
  49225. * | 2 | ALPHABLEND | |
  49226. * | 3 | ALPHATESTANDBLEND | |
  49227. *
  49228. */
  49229. transparencyMode: Nullable<number>;
  49230. /**
  49231. * Returns true if alpha blending should be disabled.
  49232. */
  49233. private readonly _disableAlphaBlending;
  49234. /**
  49235. * Specifies whether or not this material should be rendered in alpha blend mode.
  49236. */
  49237. needAlphaBlending(): boolean;
  49238. /**
  49239. * Specifies if the mesh will require alpha blending.
  49240. * @param mesh - BJS mesh.
  49241. */
  49242. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  49243. /**
  49244. * Specifies whether or not this material should be rendered in alpha test mode.
  49245. */
  49246. needAlphaTesting(): boolean;
  49247. /**
  49248. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  49249. */
  49250. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  49251. /**
  49252. * Gets the texture used for the alpha test.
  49253. */
  49254. getAlphaTestTexture(): Nullable<BaseTexture>;
  49255. /**
  49256. * Specifies that the submesh is ready to be used.
  49257. * @param mesh - BJS mesh.
  49258. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  49259. * @param useInstances - Specifies that instances should be used.
  49260. * @returns - boolean indicating that the submesh is ready or not.
  49261. */
  49262. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49263. /**
  49264. * Specifies if the material uses metallic roughness workflow.
  49265. * @returns boolean specifiying if the material uses metallic roughness workflow.
  49266. */
  49267. isMetallicWorkflow(): boolean;
  49268. private _prepareEffect;
  49269. private _prepareDefines;
  49270. /**
  49271. * Force shader compilation
  49272. */
  49273. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  49274. /**
  49275. * Initializes the uniform buffer layout for the shader.
  49276. */
  49277. buildUniformLayout(): void;
  49278. /**
  49279. * Unbinds the material from the mesh
  49280. */
  49281. unbind(): void;
  49282. /**
  49283. * Binds the submesh data.
  49284. * @param world - The world matrix.
  49285. * @param mesh - The BJS mesh.
  49286. * @param subMesh - A submesh of the BJS mesh.
  49287. */
  49288. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49289. /**
  49290. * Returns the animatable textures.
  49291. * @returns - Array of animatable textures.
  49292. */
  49293. getAnimatables(): IAnimatable[];
  49294. /**
  49295. * Returns the texture used for reflections.
  49296. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  49297. */
  49298. private _getReflectionTexture;
  49299. /**
  49300. * Returns an array of the actively used textures.
  49301. * @returns - Array of BaseTextures
  49302. */
  49303. getActiveTextures(): BaseTexture[];
  49304. /**
  49305. * Checks to see if a texture is used in the material.
  49306. * @param texture - Base texture to use.
  49307. * @returns - Boolean specifying if a texture is used in the material.
  49308. */
  49309. hasTexture(texture: BaseTexture): boolean;
  49310. /**
  49311. * Disposes the resources of the material.
  49312. * @param forceDisposeEffect - Forces the disposal of effects.
  49313. * @param forceDisposeTextures - Forces the disposal of all textures.
  49314. */
  49315. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49316. }
  49317. }
  49318. declare module BABYLON {
  49319. /**
  49320. * The Physically based material of BJS.
  49321. *
  49322. * This offers the main features of a standard PBR material.
  49323. * For more information, please refer to the documentation :
  49324. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49325. */
  49326. export class PBRMaterial extends PBRBaseMaterial {
  49327. /**
  49328. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49329. */
  49330. static readonly PBRMATERIAL_OPAQUE: number;
  49331. /**
  49332. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49333. */
  49334. static readonly PBRMATERIAL_ALPHATEST: number;
  49335. /**
  49336. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49337. */
  49338. static readonly PBRMATERIAL_ALPHABLEND: number;
  49339. /**
  49340. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49341. * They are also discarded below the alpha cutoff threshold to improve performances.
  49342. */
  49343. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49344. /**
  49345. * Defines the default value of how much AO map is occluding the analytical lights
  49346. * (point spot...).
  49347. */
  49348. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49349. /**
  49350. * Intensity of the direct lights e.g. the four lights available in your scene.
  49351. * This impacts both the direct diffuse and specular highlights.
  49352. */
  49353. directIntensity: number;
  49354. /**
  49355. * Intensity of the emissive part of the material.
  49356. * This helps controlling the emissive effect without modifying the emissive color.
  49357. */
  49358. emissiveIntensity: number;
  49359. /**
  49360. * Intensity of the environment e.g. how much the environment will light the object
  49361. * either through harmonics for rough material or through the refelction for shiny ones.
  49362. */
  49363. environmentIntensity: number;
  49364. /**
  49365. * This is a special control allowing the reduction of the specular highlights coming from the
  49366. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49367. */
  49368. specularIntensity: number;
  49369. /**
  49370. * Debug Control allowing disabling the bump map on this material.
  49371. */
  49372. disableBumpMap: boolean;
  49373. /**
  49374. * AKA Diffuse Texture in standard nomenclature.
  49375. */
  49376. albedoTexture: BaseTexture;
  49377. /**
  49378. * AKA Occlusion Texture in other nomenclature.
  49379. */
  49380. ambientTexture: BaseTexture;
  49381. /**
  49382. * AKA Occlusion Texture Intensity in other nomenclature.
  49383. */
  49384. ambientTextureStrength: number;
  49385. /**
  49386. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49387. * 1 means it completely occludes it
  49388. * 0 mean it has no impact
  49389. */
  49390. ambientTextureImpactOnAnalyticalLights: number;
  49391. /**
  49392. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  49393. */
  49394. opacityTexture: BaseTexture;
  49395. /**
  49396. * Stores the reflection values in a texture.
  49397. */
  49398. reflectionTexture: Nullable<BaseTexture>;
  49399. /**
  49400. * Stores the emissive values in a texture.
  49401. */
  49402. emissiveTexture: BaseTexture;
  49403. /**
  49404. * AKA Specular texture in other nomenclature.
  49405. */
  49406. reflectivityTexture: BaseTexture;
  49407. /**
  49408. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49409. */
  49410. metallicTexture: BaseTexture;
  49411. /**
  49412. * Specifies the metallic scalar of the metallic/roughness workflow.
  49413. * Can also be used to scale the metalness values of the metallic texture.
  49414. */
  49415. metallic: Nullable<number>;
  49416. /**
  49417. * Specifies the roughness scalar of the metallic/roughness workflow.
  49418. * Can also be used to scale the roughness values of the metallic texture.
  49419. */
  49420. roughness: Nullable<number>;
  49421. /**
  49422. * Specifies the an F0 factor to help configuring the material F0.
  49423. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  49424. * to 0.5 the previously hard coded value stays the same.
  49425. * Can also be used to scale the F0 values of the metallic texture.
  49426. */
  49427. metallicF0Factor: number;
  49428. /**
  49429. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  49430. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  49431. * your expectation as it multiplies with the texture data.
  49432. */
  49433. useMetallicF0FactorFromMetallicTexture: boolean;
  49434. /**
  49435. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49436. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49437. */
  49438. microSurfaceTexture: BaseTexture;
  49439. /**
  49440. * Stores surface normal data used to displace a mesh in a texture.
  49441. */
  49442. bumpTexture: BaseTexture;
  49443. /**
  49444. * Stores the pre-calculated light information of a mesh in a texture.
  49445. */
  49446. lightmapTexture: BaseTexture;
  49447. /**
  49448. * Stores the refracted light information in a texture.
  49449. */
  49450. refractionTexture: Nullable<BaseTexture>;
  49451. /**
  49452. * The color of a material in ambient lighting.
  49453. */
  49454. ambientColor: Color3;
  49455. /**
  49456. * AKA Diffuse Color in other nomenclature.
  49457. */
  49458. albedoColor: Color3;
  49459. /**
  49460. * AKA Specular Color in other nomenclature.
  49461. */
  49462. reflectivityColor: Color3;
  49463. /**
  49464. * The color reflected from the material.
  49465. */
  49466. reflectionColor: Color3;
  49467. /**
  49468. * The color emitted from the material.
  49469. */
  49470. emissiveColor: Color3;
  49471. /**
  49472. * AKA Glossiness in other nomenclature.
  49473. */
  49474. microSurface: number;
  49475. /**
  49476. * source material index of refraction (IOR)' / 'destination material IOR.
  49477. */
  49478. indexOfRefraction: number;
  49479. /**
  49480. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49481. */
  49482. invertRefractionY: boolean;
  49483. /**
  49484. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49485. * Materials half opaque for instance using refraction could benefit from this control.
  49486. */
  49487. linkRefractionWithTransparency: boolean;
  49488. /**
  49489. * If true, the light map contains occlusion information instead of lighting info.
  49490. */
  49491. useLightmapAsShadowmap: boolean;
  49492. /**
  49493. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49494. */
  49495. useAlphaFromAlbedoTexture: boolean;
  49496. /**
  49497. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49498. */
  49499. forceAlphaTest: boolean;
  49500. /**
  49501. * Defines the alpha limits in alpha test mode.
  49502. */
  49503. alphaCutOff: number;
  49504. /**
  49505. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49506. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49507. */
  49508. useSpecularOverAlpha: boolean;
  49509. /**
  49510. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49511. */
  49512. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49513. /**
  49514. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49515. */
  49516. useRoughnessFromMetallicTextureAlpha: boolean;
  49517. /**
  49518. * Specifies if the metallic texture contains the roughness information in its green channel.
  49519. */
  49520. useRoughnessFromMetallicTextureGreen: boolean;
  49521. /**
  49522. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49523. */
  49524. useMetallnessFromMetallicTextureBlue: boolean;
  49525. /**
  49526. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49527. */
  49528. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49529. /**
  49530. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49531. */
  49532. useAmbientInGrayScale: boolean;
  49533. /**
  49534. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49535. * The material will try to infer what glossiness each pixel should be.
  49536. */
  49537. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49538. /**
  49539. * BJS is using an harcoded light falloff based on a manually sets up range.
  49540. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49541. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49542. */
  49543. /**
  49544. * BJS is using an harcoded light falloff based on a manually sets up range.
  49545. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49546. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49547. */
  49548. usePhysicalLightFalloff: boolean;
  49549. /**
  49550. * In order to support the falloff compatibility with gltf, a special mode has been added
  49551. * to reproduce the gltf light falloff.
  49552. */
  49553. /**
  49554. * In order to support the falloff compatibility with gltf, a special mode has been added
  49555. * to reproduce the gltf light falloff.
  49556. */
  49557. useGLTFLightFalloff: boolean;
  49558. /**
  49559. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49560. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49561. */
  49562. useRadianceOverAlpha: boolean;
  49563. /**
  49564. * Allows using an object space normal map (instead of tangent space).
  49565. */
  49566. useObjectSpaceNormalMap: boolean;
  49567. /**
  49568. * Allows using the bump map in parallax mode.
  49569. */
  49570. useParallax: boolean;
  49571. /**
  49572. * Allows using the bump map in parallax occlusion mode.
  49573. */
  49574. useParallaxOcclusion: boolean;
  49575. /**
  49576. * Controls the scale bias of the parallax mode.
  49577. */
  49578. parallaxScaleBias: number;
  49579. /**
  49580. * If sets to true, disables all the lights affecting the material.
  49581. */
  49582. disableLighting: boolean;
  49583. /**
  49584. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49585. */
  49586. forceIrradianceInFragment: boolean;
  49587. /**
  49588. * Number of Simultaneous lights allowed on the material.
  49589. */
  49590. maxSimultaneousLights: number;
  49591. /**
  49592. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49593. */
  49594. invertNormalMapX: boolean;
  49595. /**
  49596. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49597. */
  49598. invertNormalMapY: boolean;
  49599. /**
  49600. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49601. */
  49602. twoSidedLighting: boolean;
  49603. /**
  49604. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49605. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49606. */
  49607. useAlphaFresnel: boolean;
  49608. /**
  49609. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49610. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49611. */
  49612. useLinearAlphaFresnel: boolean;
  49613. /**
  49614. * Let user defines the brdf lookup texture used for IBL.
  49615. * A default 8bit version is embedded but you could point at :
  49616. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49617. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49618. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49619. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49620. */
  49621. environmentBRDFTexture: Nullable<BaseTexture>;
  49622. /**
  49623. * Force normal to face away from face.
  49624. */
  49625. forceNormalForward: boolean;
  49626. /**
  49627. * Enables specular anti aliasing in the PBR shader.
  49628. * It will both interacts on the Geometry for analytical and IBL lighting.
  49629. * It also prefilter the roughness map based on the bump values.
  49630. */
  49631. enableSpecularAntiAliasing: boolean;
  49632. /**
  49633. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49634. * makes the reflect vector face the model (under horizon).
  49635. */
  49636. useHorizonOcclusion: boolean;
  49637. /**
  49638. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49639. * too much the area relying on ambient texture to define their ambient occlusion.
  49640. */
  49641. useRadianceOcclusion: boolean;
  49642. /**
  49643. * If set to true, no lighting calculations will be applied.
  49644. */
  49645. unlit: boolean;
  49646. /**
  49647. * Gets the image processing configuration used either in this material.
  49648. */
  49649. /**
  49650. * Sets the Default image processing configuration used either in the this material.
  49651. *
  49652. * If sets to null, the scene one is in use.
  49653. */
  49654. imageProcessingConfiguration: ImageProcessingConfiguration;
  49655. /**
  49656. * Gets wether the color curves effect is enabled.
  49657. */
  49658. /**
  49659. * Sets wether the color curves effect is enabled.
  49660. */
  49661. cameraColorCurvesEnabled: boolean;
  49662. /**
  49663. * Gets wether the color grading effect is enabled.
  49664. */
  49665. /**
  49666. * Gets wether the color grading effect is enabled.
  49667. */
  49668. cameraColorGradingEnabled: boolean;
  49669. /**
  49670. * Gets wether tonemapping is enabled or not.
  49671. */
  49672. /**
  49673. * Sets wether tonemapping is enabled or not
  49674. */
  49675. cameraToneMappingEnabled: boolean;
  49676. /**
  49677. * The camera exposure used on this material.
  49678. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49679. * This corresponds to a photographic exposure.
  49680. */
  49681. /**
  49682. * The camera exposure used on this material.
  49683. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49684. * This corresponds to a photographic exposure.
  49685. */
  49686. cameraExposure: number;
  49687. /**
  49688. * Gets The camera contrast used on this material.
  49689. */
  49690. /**
  49691. * Sets The camera contrast used on this material.
  49692. */
  49693. cameraContrast: number;
  49694. /**
  49695. * Gets the Color Grading 2D Lookup Texture.
  49696. */
  49697. /**
  49698. * Sets the Color Grading 2D Lookup Texture.
  49699. */
  49700. cameraColorGradingTexture: Nullable<BaseTexture>;
  49701. /**
  49702. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49703. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49704. * 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;
  49705. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49706. */
  49707. /**
  49708. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49709. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49710. * 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;
  49711. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49712. */
  49713. cameraColorCurves: Nullable<ColorCurves>;
  49714. /**
  49715. * Instantiates a new PBRMaterial instance.
  49716. *
  49717. * @param name The material name
  49718. * @param scene The scene the material will be use in.
  49719. */
  49720. constructor(name: string, scene: Scene);
  49721. /**
  49722. * Returns the name of this material class.
  49723. */
  49724. getClassName(): string;
  49725. /**
  49726. * Makes a duplicate of the current material.
  49727. * @param name - name to use for the new material.
  49728. */
  49729. clone(name: string): PBRMaterial;
  49730. /**
  49731. * Serializes this PBR Material.
  49732. * @returns - An object with the serialized material.
  49733. */
  49734. serialize(): any;
  49735. /**
  49736. * Parses a PBR Material from a serialized object.
  49737. * @param source - Serialized object.
  49738. * @param scene - BJS scene instance.
  49739. * @param rootUrl - url for the scene object
  49740. * @returns - PBRMaterial
  49741. */
  49742. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49743. }
  49744. }
  49745. declare module BABYLON {
  49746. /**
  49747. * Direct draw surface info
  49748. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49749. */
  49750. export interface DDSInfo {
  49751. /**
  49752. * Width of the texture
  49753. */
  49754. width: number;
  49755. /**
  49756. * Width of the texture
  49757. */
  49758. height: number;
  49759. /**
  49760. * Number of Mipmaps for the texture
  49761. * @see https://en.wikipedia.org/wiki/Mipmap
  49762. */
  49763. mipmapCount: number;
  49764. /**
  49765. * If the textures format is a known fourCC format
  49766. * @see https://www.fourcc.org/
  49767. */
  49768. isFourCC: boolean;
  49769. /**
  49770. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49771. */
  49772. isRGB: boolean;
  49773. /**
  49774. * If the texture is a lumincance format
  49775. */
  49776. isLuminance: boolean;
  49777. /**
  49778. * If this is a cube texture
  49779. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49780. */
  49781. isCube: boolean;
  49782. /**
  49783. * If the texture is a compressed format eg. FOURCC_DXT1
  49784. */
  49785. isCompressed: boolean;
  49786. /**
  49787. * The dxgiFormat of the texture
  49788. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49789. */
  49790. dxgiFormat: number;
  49791. /**
  49792. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49793. */
  49794. textureType: number;
  49795. /**
  49796. * Sphericle polynomial created for the dds texture
  49797. */
  49798. sphericalPolynomial?: SphericalPolynomial;
  49799. }
  49800. /**
  49801. * Class used to provide DDS decompression tools
  49802. */
  49803. export class DDSTools {
  49804. /**
  49805. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  49806. */
  49807. static StoreLODInAlphaChannel: boolean;
  49808. /**
  49809. * Gets DDS information from an array buffer
  49810. * @param arrayBuffer defines the array buffer to read data from
  49811. * @returns the DDS information
  49812. */
  49813. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  49814. private static _FloatView;
  49815. private static _Int32View;
  49816. private static _ToHalfFloat;
  49817. private static _FromHalfFloat;
  49818. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  49819. private static _GetHalfFloatRGBAArrayBuffer;
  49820. private static _GetFloatRGBAArrayBuffer;
  49821. private static _GetFloatAsUIntRGBAArrayBuffer;
  49822. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  49823. private static _GetRGBAArrayBuffer;
  49824. private static _ExtractLongWordOrder;
  49825. private static _GetRGBArrayBuffer;
  49826. private static _GetLuminanceArrayBuffer;
  49827. /**
  49828. * Uploads DDS Levels to a Babylon Texture
  49829. * @hidden
  49830. */
  49831. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  49832. }
  49833. interface ThinEngine {
  49834. /**
  49835. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  49836. * @param rootUrl defines the url where the file to load is located
  49837. * @param scene defines the current scene
  49838. * @param lodScale defines scale to apply to the mip map selection
  49839. * @param lodOffset defines offset to apply to the mip map selection
  49840. * @param onLoad defines an optional callback raised when the texture is loaded
  49841. * @param onError defines an optional callback raised if there is an issue to load the texture
  49842. * @param format defines the format of the data
  49843. * @param forcedExtension defines the extension to use to pick the right loader
  49844. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  49845. * @returns the cube texture as an InternalTexture
  49846. */
  49847. 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;
  49848. }
  49849. }
  49850. declare module BABYLON {
  49851. /**
  49852. * Implementation of the DDS Texture Loader.
  49853. * @hidden
  49854. */
  49855. export class _DDSTextureLoader implements IInternalTextureLoader {
  49856. /**
  49857. * Defines wether the loader supports cascade loading the different faces.
  49858. */
  49859. readonly supportCascades: boolean;
  49860. /**
  49861. * This returns if the loader support the current file information.
  49862. * @param extension defines the file extension of the file being loaded
  49863. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49864. * @param fallback defines the fallback internal texture if any
  49865. * @param isBase64 defines whether the texture is encoded as a base64
  49866. * @param isBuffer defines whether the texture data are stored as a buffer
  49867. * @returns true if the loader can load the specified file
  49868. */
  49869. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49870. /**
  49871. * Transform the url before loading if required.
  49872. * @param rootUrl the url of the texture
  49873. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49874. * @returns the transformed texture
  49875. */
  49876. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49877. /**
  49878. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49879. * @param rootUrl the url of the texture
  49880. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49881. * @returns the fallback texture
  49882. */
  49883. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49884. /**
  49885. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49886. * @param data contains the texture data
  49887. * @param texture defines the BabylonJS internal texture
  49888. * @param createPolynomials will be true if polynomials have been requested
  49889. * @param onLoad defines the callback to trigger once the texture is ready
  49890. * @param onError defines the callback to trigger in case of error
  49891. */
  49892. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49893. /**
  49894. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49895. * @param data contains the texture data
  49896. * @param texture defines the BabylonJS internal texture
  49897. * @param callback defines the method to call once ready to upload
  49898. */
  49899. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49900. }
  49901. }
  49902. declare module BABYLON {
  49903. /**
  49904. * Implementation of the ENV Texture Loader.
  49905. * @hidden
  49906. */
  49907. export class _ENVTextureLoader implements IInternalTextureLoader {
  49908. /**
  49909. * Defines wether the loader supports cascade loading the different faces.
  49910. */
  49911. readonly supportCascades: boolean;
  49912. /**
  49913. * This returns if the loader support the current file information.
  49914. * @param extension defines the file extension of the file being loaded
  49915. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49916. * @param fallback defines the fallback internal texture if any
  49917. * @param isBase64 defines whether the texture is encoded as a base64
  49918. * @param isBuffer defines whether the texture data are stored as a buffer
  49919. * @returns true if the loader can load the specified file
  49920. */
  49921. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49922. /**
  49923. * Transform the url before loading if required.
  49924. * @param rootUrl the url of the texture
  49925. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49926. * @returns the transformed texture
  49927. */
  49928. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49929. /**
  49930. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49931. * @param rootUrl the url of the texture
  49932. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49933. * @returns the fallback texture
  49934. */
  49935. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49936. /**
  49937. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49938. * @param data contains the texture data
  49939. * @param texture defines the BabylonJS internal texture
  49940. * @param createPolynomials will be true if polynomials have been requested
  49941. * @param onLoad defines the callback to trigger once the texture is ready
  49942. * @param onError defines the callback to trigger in case of error
  49943. */
  49944. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49945. /**
  49946. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49947. * @param data contains the texture data
  49948. * @param texture defines the BabylonJS internal texture
  49949. * @param callback defines the method to call once ready to upload
  49950. */
  49951. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49952. }
  49953. }
  49954. declare module BABYLON {
  49955. /**
  49956. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49957. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49958. */
  49959. export class KhronosTextureContainer {
  49960. /** contents of the KTX container file */
  49961. arrayBuffer: any;
  49962. private static HEADER_LEN;
  49963. private static COMPRESSED_2D;
  49964. private static COMPRESSED_3D;
  49965. private static TEX_2D;
  49966. private static TEX_3D;
  49967. /**
  49968. * Gets the openGL type
  49969. */
  49970. glType: number;
  49971. /**
  49972. * Gets the openGL type size
  49973. */
  49974. glTypeSize: number;
  49975. /**
  49976. * Gets the openGL format
  49977. */
  49978. glFormat: number;
  49979. /**
  49980. * Gets the openGL internal format
  49981. */
  49982. glInternalFormat: number;
  49983. /**
  49984. * Gets the base internal format
  49985. */
  49986. glBaseInternalFormat: number;
  49987. /**
  49988. * Gets image width in pixel
  49989. */
  49990. pixelWidth: number;
  49991. /**
  49992. * Gets image height in pixel
  49993. */
  49994. pixelHeight: number;
  49995. /**
  49996. * Gets image depth in pixels
  49997. */
  49998. pixelDepth: number;
  49999. /**
  50000. * Gets the number of array elements
  50001. */
  50002. numberOfArrayElements: number;
  50003. /**
  50004. * Gets the number of faces
  50005. */
  50006. numberOfFaces: number;
  50007. /**
  50008. * Gets the number of mipmap levels
  50009. */
  50010. numberOfMipmapLevels: number;
  50011. /**
  50012. * Gets the bytes of key value data
  50013. */
  50014. bytesOfKeyValueData: number;
  50015. /**
  50016. * Gets the load type
  50017. */
  50018. loadType: number;
  50019. /**
  50020. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50021. */
  50022. isInvalid: boolean;
  50023. /**
  50024. * Creates a new KhronosTextureContainer
  50025. * @param arrayBuffer contents of the KTX container file
  50026. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50027. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50028. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50029. */
  50030. constructor(
  50031. /** contents of the KTX container file */
  50032. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50033. /**
  50034. * Uploads KTX content to a Babylon Texture.
  50035. * It is assumed that the texture has already been created & is currently bound
  50036. * @hidden
  50037. */
  50038. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50039. private _upload2DCompressedLevels;
  50040. }
  50041. }
  50042. declare module BABYLON {
  50043. /**
  50044. * Implementation of the KTX Texture Loader.
  50045. * @hidden
  50046. */
  50047. export class _KTXTextureLoader implements IInternalTextureLoader {
  50048. /**
  50049. * Defines wether the loader supports cascade loading the different faces.
  50050. */
  50051. readonly supportCascades: boolean;
  50052. /**
  50053. * This returns if the loader support the current file information.
  50054. * @param extension defines the file extension of the file being loaded
  50055. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50056. * @param fallback defines the fallback internal texture if any
  50057. * @param isBase64 defines whether the texture is encoded as a base64
  50058. * @param isBuffer defines whether the texture data are stored as a buffer
  50059. * @returns true if the loader can load the specified file
  50060. */
  50061. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50062. /**
  50063. * Transform the url before loading if required.
  50064. * @param rootUrl the url of the texture
  50065. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50066. * @returns the transformed texture
  50067. */
  50068. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50069. /**
  50070. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50071. * @param rootUrl the url of the texture
  50072. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50073. * @returns the fallback texture
  50074. */
  50075. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50076. /**
  50077. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50078. * @param data contains the texture data
  50079. * @param texture defines the BabylonJS internal texture
  50080. * @param createPolynomials will be true if polynomials have been requested
  50081. * @param onLoad defines the callback to trigger once the texture is ready
  50082. * @param onError defines the callback to trigger in case of error
  50083. */
  50084. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50085. /**
  50086. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50087. * @param data contains the texture data
  50088. * @param texture defines the BabylonJS internal texture
  50089. * @param callback defines the method to call once ready to upload
  50090. */
  50091. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50092. }
  50093. }
  50094. declare module BABYLON {
  50095. /** @hidden */
  50096. export var _forceSceneHelpersToBundle: boolean;
  50097. interface Scene {
  50098. /**
  50099. * Creates a default light for the scene.
  50100. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50101. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50102. */
  50103. createDefaultLight(replace?: boolean): void;
  50104. /**
  50105. * Creates a default camera for the scene.
  50106. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50107. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50108. * @param replace has default false, when true replaces the active camera in the scene
  50109. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50110. */
  50111. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50112. /**
  50113. * Creates a default camera and a default light.
  50114. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50115. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50116. * @param replace has the default false, when true replaces the active camera/light in the scene
  50117. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50118. */
  50119. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50120. /**
  50121. * Creates a new sky box
  50122. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50123. * @param environmentTexture defines the texture to use as environment texture
  50124. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50125. * @param scale defines the overall scale of the skybox
  50126. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50127. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50128. * @returns a new mesh holding the sky box
  50129. */
  50130. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50131. /**
  50132. * Creates a new environment
  50133. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  50134. * @param options defines the options you can use to configure the environment
  50135. * @returns the new EnvironmentHelper
  50136. */
  50137. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  50138. /**
  50139. * Creates a new VREXperienceHelper
  50140. * @see http://doc.babylonjs.com/how_to/webvr_helper
  50141. * @param webVROptions defines the options used to create the new VREXperienceHelper
  50142. * @returns a new VREXperienceHelper
  50143. */
  50144. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  50145. /**
  50146. * Creates a new WebXRDefaultExperience
  50147. * @see http://doc.babylonjs.com/how_to/webxr
  50148. * @param options experience options
  50149. * @returns a promise for a new WebXRDefaultExperience
  50150. */
  50151. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50152. }
  50153. }
  50154. declare module BABYLON {
  50155. /**
  50156. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50157. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50158. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50159. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50160. */
  50161. export class VideoDome extends TransformNode {
  50162. /**
  50163. * Define the video source as a Monoscopic panoramic 360 video.
  50164. */
  50165. static readonly MODE_MONOSCOPIC: number;
  50166. /**
  50167. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50168. */
  50169. static readonly MODE_TOPBOTTOM: number;
  50170. /**
  50171. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50172. */
  50173. static readonly MODE_SIDEBYSIDE: number;
  50174. private _halfDome;
  50175. private _useDirectMapping;
  50176. /**
  50177. * The video texture being displayed on the sphere
  50178. */
  50179. protected _videoTexture: VideoTexture;
  50180. /**
  50181. * Gets the video texture being displayed on the sphere
  50182. */
  50183. readonly videoTexture: VideoTexture;
  50184. /**
  50185. * The skybox material
  50186. */
  50187. protected _material: BackgroundMaterial;
  50188. /**
  50189. * The surface used for the skybox
  50190. */
  50191. protected _mesh: Mesh;
  50192. /**
  50193. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50194. */
  50195. private _halfDomeMask;
  50196. /**
  50197. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50198. * Also see the options.resolution property.
  50199. */
  50200. fovMultiplier: number;
  50201. private _videoMode;
  50202. /**
  50203. * Gets or set the current video mode for the video. It can be:
  50204. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50205. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50206. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50207. */
  50208. videoMode: number;
  50209. /**
  50210. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50211. *
  50212. */
  50213. /**
  50214. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50215. */
  50216. halfDome: boolean;
  50217. /**
  50218. * Oberserver used in Stereoscopic VR Mode.
  50219. */
  50220. private _onBeforeCameraRenderObserver;
  50221. /**
  50222. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50223. * @param name Element's name, child elements will append suffixes for their own names.
  50224. * @param urlsOrVideo defines the url(s) or the video element to use
  50225. * @param options An object containing optional or exposed sub element properties
  50226. */
  50227. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50228. resolution?: number;
  50229. clickToPlay?: boolean;
  50230. autoPlay?: boolean;
  50231. loop?: boolean;
  50232. size?: number;
  50233. poster?: string;
  50234. faceForward?: boolean;
  50235. useDirectMapping?: boolean;
  50236. halfDomeMode?: boolean;
  50237. }, scene: Scene);
  50238. private _changeVideoMode;
  50239. /**
  50240. * Releases resources associated with this node.
  50241. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50242. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50243. */
  50244. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50245. }
  50246. }
  50247. declare module BABYLON {
  50248. /**
  50249. * This class can be used to get instrumentation data from a Babylon engine
  50250. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50251. */
  50252. export class EngineInstrumentation implements IDisposable {
  50253. /**
  50254. * Define the instrumented engine.
  50255. */
  50256. engine: Engine;
  50257. private _captureGPUFrameTime;
  50258. private _gpuFrameTimeToken;
  50259. private _gpuFrameTime;
  50260. private _captureShaderCompilationTime;
  50261. private _shaderCompilationTime;
  50262. private _onBeginFrameObserver;
  50263. private _onEndFrameObserver;
  50264. private _onBeforeShaderCompilationObserver;
  50265. private _onAfterShaderCompilationObserver;
  50266. /**
  50267. * Gets the perf counter used for GPU frame time
  50268. */
  50269. readonly gpuFrameTimeCounter: PerfCounter;
  50270. /**
  50271. * Gets the GPU frame time capture status
  50272. */
  50273. /**
  50274. * Enable or disable the GPU frame time capture
  50275. */
  50276. captureGPUFrameTime: boolean;
  50277. /**
  50278. * Gets the perf counter used for shader compilation time
  50279. */
  50280. readonly shaderCompilationTimeCounter: PerfCounter;
  50281. /**
  50282. * Gets the shader compilation time capture status
  50283. */
  50284. /**
  50285. * Enable or disable the shader compilation time capture
  50286. */
  50287. captureShaderCompilationTime: boolean;
  50288. /**
  50289. * Instantiates a new engine instrumentation.
  50290. * This class can be used to get instrumentation data from a Babylon engine
  50291. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50292. * @param engine Defines the engine to instrument
  50293. */
  50294. constructor(
  50295. /**
  50296. * Define the instrumented engine.
  50297. */
  50298. engine: Engine);
  50299. /**
  50300. * Dispose and release associated resources.
  50301. */
  50302. dispose(): void;
  50303. }
  50304. }
  50305. declare module BABYLON {
  50306. /**
  50307. * This class can be used to get instrumentation data from a Babylon engine
  50308. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50309. */
  50310. export class SceneInstrumentation implements IDisposable {
  50311. /**
  50312. * Defines the scene to instrument
  50313. */
  50314. scene: Scene;
  50315. private _captureActiveMeshesEvaluationTime;
  50316. private _activeMeshesEvaluationTime;
  50317. private _captureRenderTargetsRenderTime;
  50318. private _renderTargetsRenderTime;
  50319. private _captureFrameTime;
  50320. private _frameTime;
  50321. private _captureRenderTime;
  50322. private _renderTime;
  50323. private _captureInterFrameTime;
  50324. private _interFrameTime;
  50325. private _captureParticlesRenderTime;
  50326. private _particlesRenderTime;
  50327. private _captureSpritesRenderTime;
  50328. private _spritesRenderTime;
  50329. private _capturePhysicsTime;
  50330. private _physicsTime;
  50331. private _captureAnimationsTime;
  50332. private _animationsTime;
  50333. private _captureCameraRenderTime;
  50334. private _cameraRenderTime;
  50335. private _onBeforeActiveMeshesEvaluationObserver;
  50336. private _onAfterActiveMeshesEvaluationObserver;
  50337. private _onBeforeRenderTargetsRenderObserver;
  50338. private _onAfterRenderTargetsRenderObserver;
  50339. private _onAfterRenderObserver;
  50340. private _onBeforeDrawPhaseObserver;
  50341. private _onAfterDrawPhaseObserver;
  50342. private _onBeforeAnimationsObserver;
  50343. private _onBeforeParticlesRenderingObserver;
  50344. private _onAfterParticlesRenderingObserver;
  50345. private _onBeforeSpritesRenderingObserver;
  50346. private _onAfterSpritesRenderingObserver;
  50347. private _onBeforePhysicsObserver;
  50348. private _onAfterPhysicsObserver;
  50349. private _onAfterAnimationsObserver;
  50350. private _onBeforeCameraRenderObserver;
  50351. private _onAfterCameraRenderObserver;
  50352. /**
  50353. * Gets the perf counter used for active meshes evaluation time
  50354. */
  50355. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50356. /**
  50357. * Gets the active meshes evaluation time capture status
  50358. */
  50359. /**
  50360. * Enable or disable the active meshes evaluation time capture
  50361. */
  50362. captureActiveMeshesEvaluationTime: boolean;
  50363. /**
  50364. * Gets the perf counter used for render targets render time
  50365. */
  50366. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50367. /**
  50368. * Gets the render targets render time capture status
  50369. */
  50370. /**
  50371. * Enable or disable the render targets render time capture
  50372. */
  50373. captureRenderTargetsRenderTime: boolean;
  50374. /**
  50375. * Gets the perf counter used for particles render time
  50376. */
  50377. readonly particlesRenderTimeCounter: PerfCounter;
  50378. /**
  50379. * Gets the particles render time capture status
  50380. */
  50381. /**
  50382. * Enable or disable the particles render time capture
  50383. */
  50384. captureParticlesRenderTime: boolean;
  50385. /**
  50386. * Gets the perf counter used for sprites render time
  50387. */
  50388. readonly spritesRenderTimeCounter: PerfCounter;
  50389. /**
  50390. * Gets the sprites render time capture status
  50391. */
  50392. /**
  50393. * Enable or disable the sprites render time capture
  50394. */
  50395. captureSpritesRenderTime: boolean;
  50396. /**
  50397. * Gets the perf counter used for physics time
  50398. */
  50399. readonly physicsTimeCounter: PerfCounter;
  50400. /**
  50401. * Gets the physics time capture status
  50402. */
  50403. /**
  50404. * Enable or disable the physics time capture
  50405. */
  50406. capturePhysicsTime: boolean;
  50407. /**
  50408. * Gets the perf counter used for animations time
  50409. */
  50410. readonly animationsTimeCounter: PerfCounter;
  50411. /**
  50412. * Gets the animations time capture status
  50413. */
  50414. /**
  50415. * Enable or disable the animations time capture
  50416. */
  50417. captureAnimationsTime: boolean;
  50418. /**
  50419. * Gets the perf counter used for frame time capture
  50420. */
  50421. readonly frameTimeCounter: PerfCounter;
  50422. /**
  50423. * Gets the frame time capture status
  50424. */
  50425. /**
  50426. * Enable or disable the frame time capture
  50427. */
  50428. captureFrameTime: boolean;
  50429. /**
  50430. * Gets the perf counter used for inter-frames time capture
  50431. */
  50432. readonly interFrameTimeCounter: PerfCounter;
  50433. /**
  50434. * Gets the inter-frames time capture status
  50435. */
  50436. /**
  50437. * Enable or disable the inter-frames time capture
  50438. */
  50439. captureInterFrameTime: boolean;
  50440. /**
  50441. * Gets the perf counter used for render time capture
  50442. */
  50443. readonly renderTimeCounter: PerfCounter;
  50444. /**
  50445. * Gets the render time capture status
  50446. */
  50447. /**
  50448. * Enable or disable the render time capture
  50449. */
  50450. captureRenderTime: boolean;
  50451. /**
  50452. * Gets the perf counter used for camera render time capture
  50453. */
  50454. readonly cameraRenderTimeCounter: PerfCounter;
  50455. /**
  50456. * Gets the camera render time capture status
  50457. */
  50458. /**
  50459. * Enable or disable the camera render time capture
  50460. */
  50461. captureCameraRenderTime: boolean;
  50462. /**
  50463. * Gets the perf counter used for draw calls
  50464. */
  50465. readonly drawCallsCounter: PerfCounter;
  50466. /**
  50467. * Instantiates a new scene instrumentation.
  50468. * This class can be used to get instrumentation data from a Babylon engine
  50469. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50470. * @param scene Defines the scene to instrument
  50471. */
  50472. constructor(
  50473. /**
  50474. * Defines the scene to instrument
  50475. */
  50476. scene: Scene);
  50477. /**
  50478. * Dispose and release associated resources.
  50479. */
  50480. dispose(): void;
  50481. }
  50482. }
  50483. declare module BABYLON {
  50484. /** @hidden */
  50485. export var glowMapGenerationPixelShader: {
  50486. name: string;
  50487. shader: string;
  50488. };
  50489. }
  50490. declare module BABYLON {
  50491. /** @hidden */
  50492. export var glowMapGenerationVertexShader: {
  50493. name: string;
  50494. shader: string;
  50495. };
  50496. }
  50497. declare module BABYLON {
  50498. /**
  50499. * Effect layer options. This helps customizing the behaviour
  50500. * of the effect layer.
  50501. */
  50502. export interface IEffectLayerOptions {
  50503. /**
  50504. * Multiplication factor apply to the canvas size to compute the render target size
  50505. * used to generated the objects (the smaller the faster).
  50506. */
  50507. mainTextureRatio: number;
  50508. /**
  50509. * Enforces a fixed size texture to ensure effect stability across devices.
  50510. */
  50511. mainTextureFixedSize?: number;
  50512. /**
  50513. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50514. */
  50515. alphaBlendingMode: number;
  50516. /**
  50517. * The camera attached to the layer.
  50518. */
  50519. camera: Nullable<Camera>;
  50520. /**
  50521. * The rendering group to draw the layer in.
  50522. */
  50523. renderingGroupId: number;
  50524. }
  50525. /**
  50526. * The effect layer Helps adding post process effect blended with the main pass.
  50527. *
  50528. * This can be for instance use to generate glow or higlight effects on the scene.
  50529. *
  50530. * The effect layer class can not be used directly and is intented to inherited from to be
  50531. * customized per effects.
  50532. */
  50533. export abstract class EffectLayer {
  50534. private _vertexBuffers;
  50535. private _indexBuffer;
  50536. private _cachedDefines;
  50537. private _effectLayerMapGenerationEffect;
  50538. private _effectLayerOptions;
  50539. private _mergeEffect;
  50540. protected _scene: Scene;
  50541. protected _engine: Engine;
  50542. protected _maxSize: number;
  50543. protected _mainTextureDesiredSize: ISize;
  50544. protected _mainTexture: RenderTargetTexture;
  50545. protected _shouldRender: boolean;
  50546. protected _postProcesses: PostProcess[];
  50547. protected _textures: BaseTexture[];
  50548. protected _emissiveTextureAndColor: {
  50549. texture: Nullable<BaseTexture>;
  50550. color: Color4;
  50551. };
  50552. /**
  50553. * The name of the layer
  50554. */
  50555. name: string;
  50556. /**
  50557. * The clear color of the texture used to generate the glow map.
  50558. */
  50559. neutralColor: Color4;
  50560. /**
  50561. * Specifies wether the highlight layer is enabled or not.
  50562. */
  50563. isEnabled: boolean;
  50564. /**
  50565. * Gets the camera attached to the layer.
  50566. */
  50567. readonly camera: Nullable<Camera>;
  50568. /**
  50569. * Gets the rendering group id the layer should render in.
  50570. */
  50571. renderingGroupId: number;
  50572. /**
  50573. * An event triggered when the effect layer has been disposed.
  50574. */
  50575. onDisposeObservable: Observable<EffectLayer>;
  50576. /**
  50577. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50578. */
  50579. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50580. /**
  50581. * An event triggered when the generated texture is being merged in the scene.
  50582. */
  50583. onBeforeComposeObservable: Observable<EffectLayer>;
  50584. /**
  50585. * An event triggered when the mesh is rendered into the effect render target.
  50586. */
  50587. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  50588. /**
  50589. * An event triggered after the mesh has been rendered into the effect render target.
  50590. */
  50591. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  50592. /**
  50593. * An event triggered when the generated texture has been merged in the scene.
  50594. */
  50595. onAfterComposeObservable: Observable<EffectLayer>;
  50596. /**
  50597. * An event triggered when the efffect layer changes its size.
  50598. */
  50599. onSizeChangedObservable: Observable<EffectLayer>;
  50600. /** @hidden */
  50601. static _SceneComponentInitialization: (scene: Scene) => void;
  50602. /**
  50603. * Instantiates a new effect Layer and references it in the scene.
  50604. * @param name The name of the layer
  50605. * @param scene The scene to use the layer in
  50606. */
  50607. constructor(
  50608. /** The Friendly of the effect in the scene */
  50609. name: string, scene: Scene);
  50610. /**
  50611. * Get the effect name of the layer.
  50612. * @return The effect name
  50613. */
  50614. abstract getEffectName(): string;
  50615. /**
  50616. * Checks for the readiness of the element composing the layer.
  50617. * @param subMesh the mesh to check for
  50618. * @param useInstances specify wether or not to use instances to render the mesh
  50619. * @return true if ready otherwise, false
  50620. */
  50621. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50622. /**
  50623. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50624. * @returns true if the effect requires stencil during the main canvas render pass.
  50625. */
  50626. abstract needStencil(): boolean;
  50627. /**
  50628. * Create the merge effect. This is the shader use to blit the information back
  50629. * to the main canvas at the end of the scene rendering.
  50630. * @returns The effect containing the shader used to merge the effect on the main canvas
  50631. */
  50632. protected abstract _createMergeEffect(): Effect;
  50633. /**
  50634. * Creates the render target textures and post processes used in the effect layer.
  50635. */
  50636. protected abstract _createTextureAndPostProcesses(): void;
  50637. /**
  50638. * Implementation specific of rendering the generating effect on the main canvas.
  50639. * @param effect The effect used to render through
  50640. */
  50641. protected abstract _internalRender(effect: Effect): void;
  50642. /**
  50643. * Sets the required values for both the emissive texture and and the main color.
  50644. */
  50645. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50646. /**
  50647. * Free any resources and references associated to a mesh.
  50648. * Internal use
  50649. * @param mesh The mesh to free.
  50650. */
  50651. abstract _disposeMesh(mesh: Mesh): void;
  50652. /**
  50653. * Serializes this layer (Glow or Highlight for example)
  50654. * @returns a serialized layer object
  50655. */
  50656. abstract serialize?(): any;
  50657. /**
  50658. * Initializes the effect layer with the required options.
  50659. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50660. */
  50661. protected _init(options: Partial<IEffectLayerOptions>): void;
  50662. /**
  50663. * Generates the index buffer of the full screen quad blending to the main canvas.
  50664. */
  50665. private _generateIndexBuffer;
  50666. /**
  50667. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50668. */
  50669. private _generateVertexBuffer;
  50670. /**
  50671. * Sets the main texture desired size which is the closest power of two
  50672. * of the engine canvas size.
  50673. */
  50674. private _setMainTextureSize;
  50675. /**
  50676. * Creates the main texture for the effect layer.
  50677. */
  50678. protected _createMainTexture(): void;
  50679. /**
  50680. * Adds specific effects defines.
  50681. * @param defines The defines to add specifics to.
  50682. */
  50683. protected _addCustomEffectDefines(defines: string[]): void;
  50684. /**
  50685. * Checks for the readiness of the element composing the layer.
  50686. * @param subMesh the mesh to check for
  50687. * @param useInstances specify wether or not to use instances to render the mesh
  50688. * @param emissiveTexture the associated emissive texture used to generate the glow
  50689. * @return true if ready otherwise, false
  50690. */
  50691. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  50692. /**
  50693. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  50694. */
  50695. render(): void;
  50696. /**
  50697. * Determine if a given mesh will be used in the current effect.
  50698. * @param mesh mesh to test
  50699. * @returns true if the mesh will be used
  50700. */
  50701. hasMesh(mesh: AbstractMesh): boolean;
  50702. /**
  50703. * Returns true if the layer contains information to display, otherwise false.
  50704. * @returns true if the glow layer should be rendered
  50705. */
  50706. shouldRender(): boolean;
  50707. /**
  50708. * Returns true if the mesh should render, otherwise false.
  50709. * @param mesh The mesh to render
  50710. * @returns true if it should render otherwise false
  50711. */
  50712. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  50713. /**
  50714. * Returns true if the mesh can be rendered, otherwise false.
  50715. * @param mesh The mesh to render
  50716. * @param material The material used on the mesh
  50717. * @returns true if it can be rendered otherwise false
  50718. */
  50719. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50720. /**
  50721. * Returns true if the mesh should render, otherwise false.
  50722. * @param mesh The mesh to render
  50723. * @returns true if it should render otherwise false
  50724. */
  50725. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  50726. /**
  50727. * Renders the submesh passed in parameter to the generation map.
  50728. */
  50729. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  50730. /**
  50731. * Defines wether the current material of the mesh should be use to render the effect.
  50732. * @param mesh defines the current mesh to render
  50733. */
  50734. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  50735. /**
  50736. * Rebuild the required buffers.
  50737. * @hidden Internal use only.
  50738. */
  50739. _rebuild(): void;
  50740. /**
  50741. * Dispose only the render target textures and post process.
  50742. */
  50743. private _disposeTextureAndPostProcesses;
  50744. /**
  50745. * Dispose the highlight layer and free resources.
  50746. */
  50747. dispose(): void;
  50748. /**
  50749. * Gets the class name of the effect layer
  50750. * @returns the string with the class name of the effect layer
  50751. */
  50752. getClassName(): string;
  50753. /**
  50754. * Creates an effect layer from parsed effect layer data
  50755. * @param parsedEffectLayer defines effect layer data
  50756. * @param scene defines the current scene
  50757. * @param rootUrl defines the root URL containing the effect layer information
  50758. * @returns a parsed effect Layer
  50759. */
  50760. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  50761. }
  50762. }
  50763. declare module BABYLON {
  50764. interface AbstractScene {
  50765. /**
  50766. * The list of effect layers (highlights/glow) added to the scene
  50767. * @see http://doc.babylonjs.com/how_to/highlight_layer
  50768. * @see http://doc.babylonjs.com/how_to/glow_layer
  50769. */
  50770. effectLayers: Array<EffectLayer>;
  50771. /**
  50772. * Removes the given effect layer from this scene.
  50773. * @param toRemove defines the effect layer to remove
  50774. * @returns the index of the removed effect layer
  50775. */
  50776. removeEffectLayer(toRemove: EffectLayer): number;
  50777. /**
  50778. * Adds the given effect layer to this scene
  50779. * @param newEffectLayer defines the effect layer to add
  50780. */
  50781. addEffectLayer(newEffectLayer: EffectLayer): void;
  50782. }
  50783. /**
  50784. * Defines the layer scene component responsible to manage any effect layers
  50785. * in a given scene.
  50786. */
  50787. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  50788. /**
  50789. * The component name helpfull to identify the component in the list of scene components.
  50790. */
  50791. readonly name: string;
  50792. /**
  50793. * The scene the component belongs to.
  50794. */
  50795. scene: Scene;
  50796. private _engine;
  50797. private _renderEffects;
  50798. private _needStencil;
  50799. private _previousStencilState;
  50800. /**
  50801. * Creates a new instance of the component for the given scene
  50802. * @param scene Defines the scene to register the component in
  50803. */
  50804. constructor(scene: Scene);
  50805. /**
  50806. * Registers the component in a given scene
  50807. */
  50808. register(): void;
  50809. /**
  50810. * Rebuilds the elements related to this component in case of
  50811. * context lost for instance.
  50812. */
  50813. rebuild(): void;
  50814. /**
  50815. * Serializes the component data to the specified json object
  50816. * @param serializationObject The object to serialize to
  50817. */
  50818. serialize(serializationObject: any): void;
  50819. /**
  50820. * Adds all the elements from the container to the scene
  50821. * @param container the container holding the elements
  50822. */
  50823. addFromContainer(container: AbstractScene): void;
  50824. /**
  50825. * Removes all the elements in the container from the scene
  50826. * @param container contains the elements to remove
  50827. * @param dispose if the removed element should be disposed (default: false)
  50828. */
  50829. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50830. /**
  50831. * Disposes the component and the associated ressources.
  50832. */
  50833. dispose(): void;
  50834. private _isReadyForMesh;
  50835. private _renderMainTexture;
  50836. private _setStencil;
  50837. private _setStencilBack;
  50838. private _draw;
  50839. private _drawCamera;
  50840. private _drawRenderingGroup;
  50841. }
  50842. }
  50843. declare module BABYLON {
  50844. /** @hidden */
  50845. export var glowMapMergePixelShader: {
  50846. name: string;
  50847. shader: string;
  50848. };
  50849. }
  50850. declare module BABYLON {
  50851. /** @hidden */
  50852. export var glowMapMergeVertexShader: {
  50853. name: string;
  50854. shader: string;
  50855. };
  50856. }
  50857. declare module BABYLON {
  50858. interface AbstractScene {
  50859. /**
  50860. * Return a the first highlight layer of the scene with a given name.
  50861. * @param name The name of the highlight layer to look for.
  50862. * @return The highlight layer if found otherwise null.
  50863. */
  50864. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50865. }
  50866. /**
  50867. * Glow layer options. This helps customizing the behaviour
  50868. * of the glow layer.
  50869. */
  50870. export interface IGlowLayerOptions {
  50871. /**
  50872. * Multiplication factor apply to the canvas size to compute the render target size
  50873. * used to generated the glowing objects (the smaller the faster).
  50874. */
  50875. mainTextureRatio: number;
  50876. /**
  50877. * Enforces a fixed size texture to ensure resize independant blur.
  50878. */
  50879. mainTextureFixedSize?: number;
  50880. /**
  50881. * How big is the kernel of the blur texture.
  50882. */
  50883. blurKernelSize: number;
  50884. /**
  50885. * The camera attached to the layer.
  50886. */
  50887. camera: Nullable<Camera>;
  50888. /**
  50889. * Enable MSAA by chosing the number of samples.
  50890. */
  50891. mainTextureSamples?: number;
  50892. /**
  50893. * The rendering group to draw the layer in.
  50894. */
  50895. renderingGroupId: number;
  50896. }
  50897. /**
  50898. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50899. *
  50900. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  50901. *
  50902. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50903. */
  50904. export class GlowLayer extends EffectLayer {
  50905. /**
  50906. * Effect Name of the layer.
  50907. */
  50908. static readonly EffectName: string;
  50909. /**
  50910. * The default blur kernel size used for the glow.
  50911. */
  50912. static DefaultBlurKernelSize: number;
  50913. /**
  50914. * The default texture size ratio used for the glow.
  50915. */
  50916. static DefaultTextureRatio: number;
  50917. /**
  50918. * Sets the kernel size of the blur.
  50919. */
  50920. /**
  50921. * Gets the kernel size of the blur.
  50922. */
  50923. blurKernelSize: number;
  50924. /**
  50925. * Sets the glow intensity.
  50926. */
  50927. /**
  50928. * Gets the glow intensity.
  50929. */
  50930. intensity: number;
  50931. private _options;
  50932. private _intensity;
  50933. private _horizontalBlurPostprocess1;
  50934. private _verticalBlurPostprocess1;
  50935. private _horizontalBlurPostprocess2;
  50936. private _verticalBlurPostprocess2;
  50937. private _blurTexture1;
  50938. private _blurTexture2;
  50939. private _postProcesses1;
  50940. private _postProcesses2;
  50941. private _includedOnlyMeshes;
  50942. private _excludedMeshes;
  50943. private _meshesUsingTheirOwnMaterials;
  50944. /**
  50945. * Callback used to let the user override the color selection on a per mesh basis
  50946. */
  50947. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50948. /**
  50949. * Callback used to let the user override the texture selection on a per mesh basis
  50950. */
  50951. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50952. /**
  50953. * Instantiates a new glow Layer and references it to the scene.
  50954. * @param name The name of the layer
  50955. * @param scene The scene to use the layer in
  50956. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50957. */
  50958. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50959. /**
  50960. * Get the effect name of the layer.
  50961. * @return The effect name
  50962. */
  50963. getEffectName(): string;
  50964. /**
  50965. * Create the merge effect. This is the shader use to blit the information back
  50966. * to the main canvas at the end of the scene rendering.
  50967. */
  50968. protected _createMergeEffect(): Effect;
  50969. /**
  50970. * Creates the render target textures and post processes used in the glow layer.
  50971. */
  50972. protected _createTextureAndPostProcesses(): void;
  50973. /**
  50974. * Checks for the readiness of the element composing the layer.
  50975. * @param subMesh the mesh to check for
  50976. * @param useInstances specify wether or not to use instances to render the mesh
  50977. * @param emissiveTexture the associated emissive texture used to generate the glow
  50978. * @return true if ready otherwise, false
  50979. */
  50980. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50981. /**
  50982. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50983. */
  50984. needStencil(): boolean;
  50985. /**
  50986. * Returns true if the mesh can be rendered, otherwise false.
  50987. * @param mesh The mesh to render
  50988. * @param material The material used on the mesh
  50989. * @returns true if it can be rendered otherwise false
  50990. */
  50991. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50992. /**
  50993. * Implementation specific of rendering the generating effect on the main canvas.
  50994. * @param effect The effect used to render through
  50995. */
  50996. protected _internalRender(effect: Effect): void;
  50997. /**
  50998. * Sets the required values for both the emissive texture and and the main color.
  50999. */
  51000. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51001. /**
  51002. * Returns true if the mesh should render, otherwise false.
  51003. * @param mesh The mesh to render
  51004. * @returns true if it should render otherwise false
  51005. */
  51006. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51007. /**
  51008. * Adds specific effects defines.
  51009. * @param defines The defines to add specifics to.
  51010. */
  51011. protected _addCustomEffectDefines(defines: string[]): void;
  51012. /**
  51013. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51014. * @param mesh The mesh to exclude from the glow layer
  51015. */
  51016. addExcludedMesh(mesh: Mesh): void;
  51017. /**
  51018. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51019. * @param mesh The mesh to remove
  51020. */
  51021. removeExcludedMesh(mesh: Mesh): void;
  51022. /**
  51023. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51024. * @param mesh The mesh to include in the glow layer
  51025. */
  51026. addIncludedOnlyMesh(mesh: Mesh): void;
  51027. /**
  51028. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51029. * @param mesh The mesh to remove
  51030. */
  51031. removeIncludedOnlyMesh(mesh: Mesh): void;
  51032. /**
  51033. * Determine if a given mesh will be used in the glow layer
  51034. * @param mesh The mesh to test
  51035. * @returns true if the mesh will be highlighted by the current glow layer
  51036. */
  51037. hasMesh(mesh: AbstractMesh): boolean;
  51038. /**
  51039. * Defines wether the current material of the mesh should be use to render the effect.
  51040. * @param mesh defines the current mesh to render
  51041. */
  51042. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  51043. /**
  51044. * Add a mesh to be rendered through its own material and not with emissive only.
  51045. * @param mesh The mesh for which we need to use its material
  51046. */
  51047. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  51048. /**
  51049. * Remove a mesh from being rendered through its own material and not with emissive only.
  51050. * @param mesh The mesh for which we need to not use its material
  51051. */
  51052. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  51053. /**
  51054. * Free any resources and references associated to a mesh.
  51055. * Internal use
  51056. * @param mesh The mesh to free.
  51057. * @hidden
  51058. */
  51059. _disposeMesh(mesh: Mesh): void;
  51060. /**
  51061. * Gets the class name of the effect layer
  51062. * @returns the string with the class name of the effect layer
  51063. */
  51064. getClassName(): string;
  51065. /**
  51066. * Serializes this glow layer
  51067. * @returns a serialized glow layer object
  51068. */
  51069. serialize(): any;
  51070. /**
  51071. * Creates a Glow Layer from parsed glow layer data
  51072. * @param parsedGlowLayer defines glow layer data
  51073. * @param scene defines the current scene
  51074. * @param rootUrl defines the root URL containing the glow layer information
  51075. * @returns a parsed Glow Layer
  51076. */
  51077. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51078. }
  51079. }
  51080. declare module BABYLON {
  51081. /** @hidden */
  51082. export var glowBlurPostProcessPixelShader: {
  51083. name: string;
  51084. shader: string;
  51085. };
  51086. }
  51087. declare module BABYLON {
  51088. interface AbstractScene {
  51089. /**
  51090. * Return a the first highlight layer of the scene with a given name.
  51091. * @param name The name of the highlight layer to look for.
  51092. * @return The highlight layer if found otherwise null.
  51093. */
  51094. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51095. }
  51096. /**
  51097. * Highlight layer options. This helps customizing the behaviour
  51098. * of the highlight layer.
  51099. */
  51100. export interface IHighlightLayerOptions {
  51101. /**
  51102. * Multiplication factor apply to the canvas size to compute the render target size
  51103. * used to generated the glowing objects (the smaller the faster).
  51104. */
  51105. mainTextureRatio: number;
  51106. /**
  51107. * Enforces a fixed size texture to ensure resize independant blur.
  51108. */
  51109. mainTextureFixedSize?: number;
  51110. /**
  51111. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51112. * of the picture to blur (the smaller the faster).
  51113. */
  51114. blurTextureSizeRatio: number;
  51115. /**
  51116. * How big in texel of the blur texture is the vertical blur.
  51117. */
  51118. blurVerticalSize: number;
  51119. /**
  51120. * How big in texel of the blur texture is the horizontal blur.
  51121. */
  51122. blurHorizontalSize: number;
  51123. /**
  51124. * Alpha blending mode used to apply the blur. Default is combine.
  51125. */
  51126. alphaBlendingMode: number;
  51127. /**
  51128. * The camera attached to the layer.
  51129. */
  51130. camera: Nullable<Camera>;
  51131. /**
  51132. * Should we display highlight as a solid stroke?
  51133. */
  51134. isStroke?: boolean;
  51135. /**
  51136. * The rendering group to draw the layer in.
  51137. */
  51138. renderingGroupId: number;
  51139. }
  51140. /**
  51141. * The highlight layer Helps adding a glow effect around a mesh.
  51142. *
  51143. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  51144. * glowy meshes to your scene.
  51145. *
  51146. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51147. */
  51148. export class HighlightLayer extends EffectLayer {
  51149. name: string;
  51150. /**
  51151. * Effect Name of the highlight layer.
  51152. */
  51153. static readonly EffectName: string;
  51154. /**
  51155. * The neutral color used during the preparation of the glow effect.
  51156. * This is black by default as the blend operation is a blend operation.
  51157. */
  51158. static NeutralColor: Color4;
  51159. /**
  51160. * Stencil value used for glowing meshes.
  51161. */
  51162. static GlowingMeshStencilReference: number;
  51163. /**
  51164. * Stencil value used for the other meshes in the scene.
  51165. */
  51166. static NormalMeshStencilReference: number;
  51167. /**
  51168. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51169. */
  51170. innerGlow: boolean;
  51171. /**
  51172. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51173. */
  51174. outerGlow: boolean;
  51175. /**
  51176. * Specifies the horizontal size of the blur.
  51177. */
  51178. /**
  51179. * Gets the horizontal size of the blur.
  51180. */
  51181. blurHorizontalSize: number;
  51182. /**
  51183. * Specifies the vertical size of the blur.
  51184. */
  51185. /**
  51186. * Gets the vertical size of the blur.
  51187. */
  51188. blurVerticalSize: number;
  51189. /**
  51190. * An event triggered when the highlight layer is being blurred.
  51191. */
  51192. onBeforeBlurObservable: Observable<HighlightLayer>;
  51193. /**
  51194. * An event triggered when the highlight layer has been blurred.
  51195. */
  51196. onAfterBlurObservable: Observable<HighlightLayer>;
  51197. private _instanceGlowingMeshStencilReference;
  51198. private _options;
  51199. private _downSamplePostprocess;
  51200. private _horizontalBlurPostprocess;
  51201. private _verticalBlurPostprocess;
  51202. private _blurTexture;
  51203. private _meshes;
  51204. private _excludedMeshes;
  51205. /**
  51206. * Instantiates a new highlight Layer and references it to the scene..
  51207. * @param name The name of the layer
  51208. * @param scene The scene to use the layer in
  51209. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51210. */
  51211. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51212. /**
  51213. * Get the effect name of the layer.
  51214. * @return The effect name
  51215. */
  51216. getEffectName(): string;
  51217. /**
  51218. * Create the merge effect. This is the shader use to blit the information back
  51219. * to the main canvas at the end of the scene rendering.
  51220. */
  51221. protected _createMergeEffect(): Effect;
  51222. /**
  51223. * Creates the render target textures and post processes used in the highlight layer.
  51224. */
  51225. protected _createTextureAndPostProcesses(): void;
  51226. /**
  51227. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51228. */
  51229. needStencil(): boolean;
  51230. /**
  51231. * Checks for the readiness of the element composing the layer.
  51232. * @param subMesh the mesh to check for
  51233. * @param useInstances specify wether or not to use instances to render the mesh
  51234. * @param emissiveTexture the associated emissive texture used to generate the glow
  51235. * @return true if ready otherwise, false
  51236. */
  51237. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51238. /**
  51239. * Implementation specific of rendering the generating effect on the main canvas.
  51240. * @param effect The effect used to render through
  51241. */
  51242. protected _internalRender(effect: Effect): void;
  51243. /**
  51244. * Returns true if the layer contains information to display, otherwise false.
  51245. */
  51246. shouldRender(): boolean;
  51247. /**
  51248. * Returns true if the mesh should render, otherwise false.
  51249. * @param mesh The mesh to render
  51250. * @returns true if it should render otherwise false
  51251. */
  51252. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51253. /**
  51254. * Sets the required values for both the emissive texture and and the main color.
  51255. */
  51256. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51257. /**
  51258. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51259. * @param mesh The mesh to exclude from the highlight layer
  51260. */
  51261. addExcludedMesh(mesh: Mesh): void;
  51262. /**
  51263. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51264. * @param mesh The mesh to highlight
  51265. */
  51266. removeExcludedMesh(mesh: Mesh): void;
  51267. /**
  51268. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51269. * @param mesh mesh to test
  51270. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51271. */
  51272. hasMesh(mesh: AbstractMesh): boolean;
  51273. /**
  51274. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51275. * @param mesh The mesh to highlight
  51276. * @param color The color of the highlight
  51277. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51278. */
  51279. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51280. /**
  51281. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51282. * @param mesh The mesh to highlight
  51283. */
  51284. removeMesh(mesh: Mesh): void;
  51285. /**
  51286. * Force the stencil to the normal expected value for none glowing parts
  51287. */
  51288. private _defaultStencilReference;
  51289. /**
  51290. * Free any resources and references associated to a mesh.
  51291. * Internal use
  51292. * @param mesh The mesh to free.
  51293. * @hidden
  51294. */
  51295. _disposeMesh(mesh: Mesh): void;
  51296. /**
  51297. * Dispose the highlight layer and free resources.
  51298. */
  51299. dispose(): void;
  51300. /**
  51301. * Gets the class name of the effect layer
  51302. * @returns the string with the class name of the effect layer
  51303. */
  51304. getClassName(): string;
  51305. /**
  51306. * Serializes this Highlight layer
  51307. * @returns a serialized Highlight layer object
  51308. */
  51309. serialize(): any;
  51310. /**
  51311. * Creates a Highlight layer from parsed Highlight layer data
  51312. * @param parsedHightlightLayer defines the Highlight layer data
  51313. * @param scene defines the current scene
  51314. * @param rootUrl defines the root URL containing the Highlight layer information
  51315. * @returns a parsed Highlight layer
  51316. */
  51317. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51318. }
  51319. }
  51320. declare module BABYLON {
  51321. interface AbstractScene {
  51322. /**
  51323. * The list of layers (background and foreground) of the scene
  51324. */
  51325. layers: Array<Layer>;
  51326. }
  51327. /**
  51328. * Defines the layer scene component responsible to manage any layers
  51329. * in a given scene.
  51330. */
  51331. export class LayerSceneComponent implements ISceneComponent {
  51332. /**
  51333. * The component name helpfull to identify the component in the list of scene components.
  51334. */
  51335. readonly name: string;
  51336. /**
  51337. * The scene the component belongs to.
  51338. */
  51339. scene: Scene;
  51340. private _engine;
  51341. /**
  51342. * Creates a new instance of the component for the given scene
  51343. * @param scene Defines the scene to register the component in
  51344. */
  51345. constructor(scene: Scene);
  51346. /**
  51347. * Registers the component in a given scene
  51348. */
  51349. register(): void;
  51350. /**
  51351. * Rebuilds the elements related to this component in case of
  51352. * context lost for instance.
  51353. */
  51354. rebuild(): void;
  51355. /**
  51356. * Disposes the component and the associated ressources.
  51357. */
  51358. dispose(): void;
  51359. private _draw;
  51360. private _drawCameraPredicate;
  51361. private _drawCameraBackground;
  51362. private _drawCameraForeground;
  51363. private _drawRenderTargetPredicate;
  51364. private _drawRenderTargetBackground;
  51365. private _drawRenderTargetForeground;
  51366. /**
  51367. * Adds all the elements from the container to the scene
  51368. * @param container the container holding the elements
  51369. */
  51370. addFromContainer(container: AbstractScene): void;
  51371. /**
  51372. * Removes all the elements in the container from the scene
  51373. * @param container contains the elements to remove
  51374. * @param dispose if the removed element should be disposed (default: false)
  51375. */
  51376. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51377. }
  51378. }
  51379. declare module BABYLON {
  51380. /** @hidden */
  51381. export var layerPixelShader: {
  51382. name: string;
  51383. shader: string;
  51384. };
  51385. }
  51386. declare module BABYLON {
  51387. /** @hidden */
  51388. export var layerVertexShader: {
  51389. name: string;
  51390. shader: string;
  51391. };
  51392. }
  51393. declare module BABYLON {
  51394. /**
  51395. * This represents a full screen 2d layer.
  51396. * This can be useful to display a picture in the background of your scene for instance.
  51397. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51398. */
  51399. export class Layer {
  51400. /**
  51401. * Define the name of the layer.
  51402. */
  51403. name: string;
  51404. /**
  51405. * Define the texture the layer should display.
  51406. */
  51407. texture: Nullable<Texture>;
  51408. /**
  51409. * Is the layer in background or foreground.
  51410. */
  51411. isBackground: boolean;
  51412. /**
  51413. * Define the color of the layer (instead of texture).
  51414. */
  51415. color: Color4;
  51416. /**
  51417. * Define the scale of the layer in order to zoom in out of the texture.
  51418. */
  51419. scale: Vector2;
  51420. /**
  51421. * Define an offset for the layer in order to shift the texture.
  51422. */
  51423. offset: Vector2;
  51424. /**
  51425. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51426. */
  51427. alphaBlendingMode: number;
  51428. /**
  51429. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51430. * Alpha test will not mix with the background color in case of transparency.
  51431. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51432. */
  51433. alphaTest: boolean;
  51434. /**
  51435. * Define a mask to restrict the layer to only some of the scene cameras.
  51436. */
  51437. layerMask: number;
  51438. /**
  51439. * Define the list of render target the layer is visible into.
  51440. */
  51441. renderTargetTextures: RenderTargetTexture[];
  51442. /**
  51443. * Define if the layer is only used in renderTarget or if it also
  51444. * renders in the main frame buffer of the canvas.
  51445. */
  51446. renderOnlyInRenderTargetTextures: boolean;
  51447. private _scene;
  51448. private _vertexBuffers;
  51449. private _indexBuffer;
  51450. private _effect;
  51451. private _previousDefines;
  51452. /**
  51453. * An event triggered when the layer is disposed.
  51454. */
  51455. onDisposeObservable: Observable<Layer>;
  51456. private _onDisposeObserver;
  51457. /**
  51458. * Back compatibility with callback before the onDisposeObservable existed.
  51459. * The set callback will be triggered when the layer has been disposed.
  51460. */
  51461. onDispose: () => void;
  51462. /**
  51463. * An event triggered before rendering the scene
  51464. */
  51465. onBeforeRenderObservable: Observable<Layer>;
  51466. private _onBeforeRenderObserver;
  51467. /**
  51468. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51469. * The set callback will be triggered just before rendering the layer.
  51470. */
  51471. onBeforeRender: () => void;
  51472. /**
  51473. * An event triggered after rendering the scene
  51474. */
  51475. onAfterRenderObservable: Observable<Layer>;
  51476. private _onAfterRenderObserver;
  51477. /**
  51478. * Back compatibility with callback before the onAfterRenderObservable existed.
  51479. * The set callback will be triggered just after rendering the layer.
  51480. */
  51481. onAfterRender: () => void;
  51482. /**
  51483. * Instantiates a new layer.
  51484. * This represents a full screen 2d layer.
  51485. * This can be useful to display a picture in the background of your scene for instance.
  51486. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51487. * @param name Define the name of the layer in the scene
  51488. * @param imgUrl Define the url of the texture to display in the layer
  51489. * @param scene Define the scene the layer belongs to
  51490. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51491. * @param color Defines a color for the layer
  51492. */
  51493. constructor(
  51494. /**
  51495. * Define the name of the layer.
  51496. */
  51497. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51498. private _createIndexBuffer;
  51499. /** @hidden */
  51500. _rebuild(): void;
  51501. /**
  51502. * Renders the layer in the scene.
  51503. */
  51504. render(): void;
  51505. /**
  51506. * Disposes and releases the associated ressources.
  51507. */
  51508. dispose(): void;
  51509. }
  51510. }
  51511. declare module BABYLON {
  51512. /** @hidden */
  51513. export var lensFlarePixelShader: {
  51514. name: string;
  51515. shader: string;
  51516. };
  51517. }
  51518. declare module BABYLON {
  51519. /** @hidden */
  51520. export var lensFlareVertexShader: {
  51521. name: string;
  51522. shader: string;
  51523. };
  51524. }
  51525. declare module BABYLON {
  51526. /**
  51527. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51528. * It is usually composed of several `lensFlare`.
  51529. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51530. */
  51531. export class LensFlareSystem {
  51532. /**
  51533. * Define the name of the lens flare system
  51534. */
  51535. name: string;
  51536. /**
  51537. * List of lens flares used in this system.
  51538. */
  51539. lensFlares: LensFlare[];
  51540. /**
  51541. * Define a limit from the border the lens flare can be visible.
  51542. */
  51543. borderLimit: number;
  51544. /**
  51545. * Define a viewport border we do not want to see the lens flare in.
  51546. */
  51547. viewportBorder: number;
  51548. /**
  51549. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51550. */
  51551. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51552. /**
  51553. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51554. */
  51555. layerMask: number;
  51556. /**
  51557. * Define the id of the lens flare system in the scene.
  51558. * (equal to name by default)
  51559. */
  51560. id: string;
  51561. private _scene;
  51562. private _emitter;
  51563. private _vertexBuffers;
  51564. private _indexBuffer;
  51565. private _effect;
  51566. private _positionX;
  51567. private _positionY;
  51568. private _isEnabled;
  51569. /** @hidden */
  51570. static _SceneComponentInitialization: (scene: Scene) => void;
  51571. /**
  51572. * Instantiates a lens flare system.
  51573. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51574. * It is usually composed of several `lensFlare`.
  51575. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51576. * @param name Define the name of the lens flare system in the scene
  51577. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51578. * @param scene Define the scene the lens flare system belongs to
  51579. */
  51580. constructor(
  51581. /**
  51582. * Define the name of the lens flare system
  51583. */
  51584. name: string, emitter: any, scene: Scene);
  51585. /**
  51586. * Define if the lens flare system is enabled.
  51587. */
  51588. isEnabled: boolean;
  51589. /**
  51590. * Get the scene the effects belongs to.
  51591. * @returns the scene holding the lens flare system
  51592. */
  51593. getScene(): Scene;
  51594. /**
  51595. * Get the emitter of the lens flare system.
  51596. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51597. * @returns the emitter of the lens flare system
  51598. */
  51599. getEmitter(): any;
  51600. /**
  51601. * Set the emitter of the lens flare system.
  51602. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51603. * @param newEmitter Define the new emitter of the system
  51604. */
  51605. setEmitter(newEmitter: any): void;
  51606. /**
  51607. * Get the lens flare system emitter position.
  51608. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  51609. * @returns the position
  51610. */
  51611. getEmitterPosition(): Vector3;
  51612. /**
  51613. * @hidden
  51614. */
  51615. computeEffectivePosition(globalViewport: Viewport): boolean;
  51616. /** @hidden */
  51617. _isVisible(): boolean;
  51618. /**
  51619. * @hidden
  51620. */
  51621. render(): boolean;
  51622. /**
  51623. * Dispose and release the lens flare with its associated resources.
  51624. */
  51625. dispose(): void;
  51626. /**
  51627. * Parse a lens flare system from a JSON repressentation
  51628. * @param parsedLensFlareSystem Define the JSON to parse
  51629. * @param scene Define the scene the parsed system should be instantiated in
  51630. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  51631. * @returns the parsed system
  51632. */
  51633. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  51634. /**
  51635. * Serialize the current Lens Flare System into a JSON representation.
  51636. * @returns the serialized JSON
  51637. */
  51638. serialize(): any;
  51639. }
  51640. }
  51641. declare module BABYLON {
  51642. /**
  51643. * This represents one of the lens effect in a `lensFlareSystem`.
  51644. * It controls one of the indiviual texture used in the effect.
  51645. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51646. */
  51647. export class LensFlare {
  51648. /**
  51649. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51650. */
  51651. size: number;
  51652. /**
  51653. * 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.
  51654. */
  51655. position: number;
  51656. /**
  51657. * Define the lens color.
  51658. */
  51659. color: Color3;
  51660. /**
  51661. * Define the lens texture.
  51662. */
  51663. texture: Nullable<Texture>;
  51664. /**
  51665. * Define the alpha mode to render this particular lens.
  51666. */
  51667. alphaMode: number;
  51668. private _system;
  51669. /**
  51670. * Creates a new Lens Flare.
  51671. * This represents one of the lens effect in a `lensFlareSystem`.
  51672. * It controls one of the indiviual texture used in the effect.
  51673. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51674. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  51675. * @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.
  51676. * @param color Define the lens color
  51677. * @param imgUrl Define the lens texture url
  51678. * @param system Define the `lensFlareSystem` this flare is part of
  51679. * @returns The newly created Lens Flare
  51680. */
  51681. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  51682. /**
  51683. * Instantiates a new Lens Flare.
  51684. * This represents one of the lens effect in a `lensFlareSystem`.
  51685. * It controls one of the indiviual texture used in the effect.
  51686. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51687. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  51688. * @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.
  51689. * @param color Define the lens color
  51690. * @param imgUrl Define the lens texture url
  51691. * @param system Define the `lensFlareSystem` this flare is part of
  51692. */
  51693. constructor(
  51694. /**
  51695. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51696. */
  51697. size: number,
  51698. /**
  51699. * 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.
  51700. */
  51701. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  51702. /**
  51703. * Dispose and release the lens flare with its associated resources.
  51704. */
  51705. dispose(): void;
  51706. }
  51707. }
  51708. declare module BABYLON {
  51709. interface AbstractScene {
  51710. /**
  51711. * The list of lens flare system added to the scene
  51712. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51713. */
  51714. lensFlareSystems: Array<LensFlareSystem>;
  51715. /**
  51716. * Removes the given lens flare system from this scene.
  51717. * @param toRemove The lens flare system to remove
  51718. * @returns The index of the removed lens flare system
  51719. */
  51720. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  51721. /**
  51722. * Adds the given lens flare system to this scene
  51723. * @param newLensFlareSystem The lens flare system to add
  51724. */
  51725. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  51726. /**
  51727. * Gets a lens flare system using its name
  51728. * @param name defines the name to look for
  51729. * @returns the lens flare system or null if not found
  51730. */
  51731. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  51732. /**
  51733. * Gets a lens flare system using its id
  51734. * @param id defines the id to look for
  51735. * @returns the lens flare system or null if not found
  51736. */
  51737. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  51738. }
  51739. /**
  51740. * Defines the lens flare scene component responsible to manage any lens flares
  51741. * in a given scene.
  51742. */
  51743. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  51744. /**
  51745. * The component name helpfull to identify the component in the list of scene components.
  51746. */
  51747. readonly name: string;
  51748. /**
  51749. * The scene the component belongs to.
  51750. */
  51751. scene: Scene;
  51752. /**
  51753. * Creates a new instance of the component for the given scene
  51754. * @param scene Defines the scene to register the component in
  51755. */
  51756. constructor(scene: Scene);
  51757. /**
  51758. * Registers the component in a given scene
  51759. */
  51760. register(): void;
  51761. /**
  51762. * Rebuilds the elements related to this component in case of
  51763. * context lost for instance.
  51764. */
  51765. rebuild(): void;
  51766. /**
  51767. * Adds all the elements from the container to the scene
  51768. * @param container the container holding the elements
  51769. */
  51770. addFromContainer(container: AbstractScene): void;
  51771. /**
  51772. * Removes all the elements in the container from the scene
  51773. * @param container contains the elements to remove
  51774. * @param dispose if the removed element should be disposed (default: false)
  51775. */
  51776. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51777. /**
  51778. * Serializes the component data to the specified json object
  51779. * @param serializationObject The object to serialize to
  51780. */
  51781. serialize(serializationObject: any): void;
  51782. /**
  51783. * Disposes the component and the associated ressources.
  51784. */
  51785. dispose(): void;
  51786. private _draw;
  51787. }
  51788. }
  51789. declare module BABYLON {
  51790. /**
  51791. * Defines the shadow generator component responsible to manage any shadow generators
  51792. * in a given scene.
  51793. */
  51794. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51795. /**
  51796. * The component name helpfull to identify the component in the list of scene components.
  51797. */
  51798. readonly name: string;
  51799. /**
  51800. * The scene the component belongs to.
  51801. */
  51802. scene: Scene;
  51803. /**
  51804. * Creates a new instance of the component for the given scene
  51805. * @param scene Defines the scene to register the component in
  51806. */
  51807. constructor(scene: Scene);
  51808. /**
  51809. * Registers the component in a given scene
  51810. */
  51811. register(): void;
  51812. /**
  51813. * Rebuilds the elements related to this component in case of
  51814. * context lost for instance.
  51815. */
  51816. rebuild(): void;
  51817. /**
  51818. * Serializes the component data to the specified json object
  51819. * @param serializationObject The object to serialize to
  51820. */
  51821. serialize(serializationObject: any): void;
  51822. /**
  51823. * Adds all the elements from the container to the scene
  51824. * @param container the container holding the elements
  51825. */
  51826. addFromContainer(container: AbstractScene): void;
  51827. /**
  51828. * Removes all the elements in the container from the scene
  51829. * @param container contains the elements to remove
  51830. * @param dispose if the removed element should be disposed (default: false)
  51831. */
  51832. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51833. /**
  51834. * Rebuilds the elements related to this component in case of
  51835. * context lost for instance.
  51836. */
  51837. dispose(): void;
  51838. private _gatherRenderTargets;
  51839. }
  51840. }
  51841. declare module BABYLON {
  51842. /**
  51843. * A point light is a light defined by an unique point in world space.
  51844. * The light is emitted in every direction from this point.
  51845. * A good example of a point light is a standard light bulb.
  51846. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51847. */
  51848. export class PointLight extends ShadowLight {
  51849. private _shadowAngle;
  51850. /**
  51851. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51852. * This specifies what angle the shadow will use to be created.
  51853. *
  51854. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51855. */
  51856. /**
  51857. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51858. * This specifies what angle the shadow will use to be created.
  51859. *
  51860. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51861. */
  51862. shadowAngle: number;
  51863. /**
  51864. * Gets the direction if it has been set.
  51865. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51866. */
  51867. /**
  51868. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51869. */
  51870. direction: Vector3;
  51871. /**
  51872. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51873. * A PointLight emits the light in every direction.
  51874. * It can cast shadows.
  51875. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51876. * ```javascript
  51877. * var pointLight = new PointLight("pl", camera.position, scene);
  51878. * ```
  51879. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51880. * @param name The light friendly name
  51881. * @param position The position of the point light in the scene
  51882. * @param scene The scene the lights belongs to
  51883. */
  51884. constructor(name: string, position: Vector3, scene: Scene);
  51885. /**
  51886. * Returns the string "PointLight"
  51887. * @returns the class name
  51888. */
  51889. getClassName(): string;
  51890. /**
  51891. * Returns the integer 0.
  51892. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51893. */
  51894. getTypeID(): number;
  51895. /**
  51896. * Specifies wether or not the shadowmap should be a cube texture.
  51897. * @returns true if the shadowmap needs to be a cube texture.
  51898. */
  51899. needCube(): boolean;
  51900. /**
  51901. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51902. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51903. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51904. */
  51905. getShadowDirection(faceIndex?: number): Vector3;
  51906. /**
  51907. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51908. * - fov = PI / 2
  51909. * - aspect ratio : 1.0
  51910. * - z-near and far equal to the active camera minZ and maxZ.
  51911. * Returns the PointLight.
  51912. */
  51913. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51914. protected _buildUniformLayout(): void;
  51915. /**
  51916. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51917. * @param effect The effect to update
  51918. * @param lightIndex The index of the light in the effect to update
  51919. * @returns The point light
  51920. */
  51921. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  51922. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51923. /**
  51924. * Prepares the list of defines specific to the light type.
  51925. * @param defines the list of defines
  51926. * @param lightIndex defines the index of the light for the effect
  51927. */
  51928. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51929. }
  51930. }
  51931. declare module BABYLON {
  51932. /**
  51933. * Header information of HDR texture files.
  51934. */
  51935. export interface HDRInfo {
  51936. /**
  51937. * The height of the texture in pixels.
  51938. */
  51939. height: number;
  51940. /**
  51941. * The width of the texture in pixels.
  51942. */
  51943. width: number;
  51944. /**
  51945. * The index of the beginning of the data in the binary file.
  51946. */
  51947. dataPosition: number;
  51948. }
  51949. /**
  51950. * This groups tools to convert HDR texture to native colors array.
  51951. */
  51952. export class HDRTools {
  51953. private static Ldexp;
  51954. private static Rgbe2float;
  51955. private static readStringLine;
  51956. /**
  51957. * Reads header information from an RGBE texture stored in a native array.
  51958. * More information on this format are available here:
  51959. * https://en.wikipedia.org/wiki/RGBE_image_format
  51960. *
  51961. * @param uint8array The binary file stored in native array.
  51962. * @return The header information.
  51963. */
  51964. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51965. /**
  51966. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51967. * This RGBE texture needs to store the information as a panorama.
  51968. *
  51969. * More information on this format are available here:
  51970. * https://en.wikipedia.org/wiki/RGBE_image_format
  51971. *
  51972. * @param buffer The binary file stored in an array buffer.
  51973. * @param size The expected size of the extracted cubemap.
  51974. * @return The Cube Map information.
  51975. */
  51976. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51977. /**
  51978. * Returns the pixels data extracted from an RGBE texture.
  51979. * This pixels will be stored left to right up to down in the R G B order in one array.
  51980. *
  51981. * More information on this format are available here:
  51982. * https://en.wikipedia.org/wiki/RGBE_image_format
  51983. *
  51984. * @param uint8array The binary file stored in an array buffer.
  51985. * @param hdrInfo The header information of the file.
  51986. * @return The pixels data in RGB right to left up to down order.
  51987. */
  51988. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51989. private static RGBE_ReadPixels_RLE;
  51990. }
  51991. }
  51992. declare module BABYLON {
  51993. /**
  51994. * This represents a texture coming from an HDR input.
  51995. *
  51996. * The only supported format is currently panorama picture stored in RGBE format.
  51997. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51998. */
  51999. export class HDRCubeTexture extends BaseTexture {
  52000. private static _facesMapping;
  52001. private _generateHarmonics;
  52002. private _noMipmap;
  52003. private _textureMatrix;
  52004. private _size;
  52005. private _onLoad;
  52006. private _onError;
  52007. /**
  52008. * The texture URL.
  52009. */
  52010. url: string;
  52011. /**
  52012. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52013. */
  52014. coordinatesMode: number;
  52015. protected _isBlocking: boolean;
  52016. /**
  52017. * Sets wether or not the texture is blocking during loading.
  52018. */
  52019. /**
  52020. * Gets wether or not the texture is blocking during loading.
  52021. */
  52022. isBlocking: boolean;
  52023. protected _rotationY: number;
  52024. /**
  52025. * Sets texture matrix rotation angle around Y axis in radians.
  52026. */
  52027. /**
  52028. * Gets texture matrix rotation angle around Y axis radians.
  52029. */
  52030. rotationY: number;
  52031. /**
  52032. * Gets or sets the center of the bounding box associated with the cube texture
  52033. * It must define where the camera used to render the texture was set
  52034. */
  52035. boundingBoxPosition: Vector3;
  52036. private _boundingBoxSize;
  52037. /**
  52038. * Gets or sets the size of the bounding box associated with the cube texture
  52039. * When defined, the cubemap will switch to local mode
  52040. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52041. * @example https://www.babylonjs-playground.com/#RNASML
  52042. */
  52043. boundingBoxSize: Vector3;
  52044. /**
  52045. * Instantiates an HDRTexture from the following parameters.
  52046. *
  52047. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52048. * @param scene The scene the texture will be used in
  52049. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52050. * @param noMipmap Forces to not generate the mipmap if true
  52051. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52052. * @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)
  52053. * @param reserved Reserved flag for internal use.
  52054. */
  52055. 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>);
  52056. /**
  52057. * Get the current class name of the texture useful for serialization or dynamic coding.
  52058. * @returns "HDRCubeTexture"
  52059. */
  52060. getClassName(): string;
  52061. /**
  52062. * Occurs when the file is raw .hdr file.
  52063. */
  52064. private loadTexture;
  52065. clone(): HDRCubeTexture;
  52066. delayLoad(): void;
  52067. /**
  52068. * Get the texture reflection matrix used to rotate/transform the reflection.
  52069. * @returns the reflection matrix
  52070. */
  52071. getReflectionTextureMatrix(): Matrix;
  52072. /**
  52073. * Set the texture reflection matrix used to rotate/transform the reflection.
  52074. * @param value Define the reflection matrix to set
  52075. */
  52076. setReflectionTextureMatrix(value: Matrix): void;
  52077. /**
  52078. * Parses a JSON representation of an HDR Texture in order to create the texture
  52079. * @param parsedTexture Define the JSON representation
  52080. * @param scene Define the scene the texture should be created in
  52081. * @param rootUrl Define the root url in case we need to load relative dependencies
  52082. * @returns the newly created texture after parsing
  52083. */
  52084. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52085. serialize(): any;
  52086. }
  52087. }
  52088. declare module BABYLON {
  52089. /**
  52090. * Class used to control physics engine
  52091. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52092. */
  52093. export class PhysicsEngine implements IPhysicsEngine {
  52094. private _physicsPlugin;
  52095. /**
  52096. * Global value used to control the smallest number supported by the simulation
  52097. */
  52098. static Epsilon: number;
  52099. private _impostors;
  52100. private _joints;
  52101. private _subTimeStep;
  52102. /**
  52103. * Gets the gravity vector used by the simulation
  52104. */
  52105. gravity: Vector3;
  52106. /**
  52107. * Factory used to create the default physics plugin.
  52108. * @returns The default physics plugin
  52109. */
  52110. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52111. /**
  52112. * Creates a new Physics Engine
  52113. * @param gravity defines the gravity vector used by the simulation
  52114. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52115. */
  52116. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52117. /**
  52118. * Sets the gravity vector used by the simulation
  52119. * @param gravity defines the gravity vector to use
  52120. */
  52121. setGravity(gravity: Vector3): void;
  52122. /**
  52123. * Set the time step of the physics engine.
  52124. * Default is 1/60.
  52125. * To slow it down, enter 1/600 for example.
  52126. * To speed it up, 1/30
  52127. * @param newTimeStep defines the new timestep to apply to this world.
  52128. */
  52129. setTimeStep(newTimeStep?: number): void;
  52130. /**
  52131. * Get the time step of the physics engine.
  52132. * @returns the current time step
  52133. */
  52134. getTimeStep(): number;
  52135. /**
  52136. * Set the sub time step of the physics engine.
  52137. * Default is 0 meaning there is no sub steps
  52138. * To increase physics resolution precision, set a small value (like 1 ms)
  52139. * @param subTimeStep defines the new sub timestep used for physics resolution.
  52140. */
  52141. setSubTimeStep(subTimeStep?: number): void;
  52142. /**
  52143. * Get the sub time step of the physics engine.
  52144. * @returns the current sub time step
  52145. */
  52146. getSubTimeStep(): number;
  52147. /**
  52148. * Release all resources
  52149. */
  52150. dispose(): void;
  52151. /**
  52152. * Gets the name of the current physics plugin
  52153. * @returns the name of the plugin
  52154. */
  52155. getPhysicsPluginName(): string;
  52156. /**
  52157. * Adding a new impostor for the impostor tracking.
  52158. * This will be done by the impostor itself.
  52159. * @param impostor the impostor to add
  52160. */
  52161. addImpostor(impostor: PhysicsImpostor): void;
  52162. /**
  52163. * Remove an impostor from the engine.
  52164. * This impostor and its mesh will not longer be updated by the physics engine.
  52165. * @param impostor the impostor to remove
  52166. */
  52167. removeImpostor(impostor: PhysicsImpostor): void;
  52168. /**
  52169. * Add a joint to the physics engine
  52170. * @param mainImpostor defines the main impostor to which the joint is added.
  52171. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52172. * @param joint defines the joint that will connect both impostors.
  52173. */
  52174. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52175. /**
  52176. * Removes a joint from the simulation
  52177. * @param mainImpostor defines the impostor used with the joint
  52178. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52179. * @param joint defines the joint to remove
  52180. */
  52181. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52182. /**
  52183. * Called by the scene. No need to call it.
  52184. * @param delta defines the timespam between frames
  52185. */
  52186. _step(delta: number): void;
  52187. /**
  52188. * Gets the current plugin used to run the simulation
  52189. * @returns current plugin
  52190. */
  52191. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52192. /**
  52193. * Gets the list of physic impostors
  52194. * @returns an array of PhysicsImpostor
  52195. */
  52196. getImpostors(): Array<PhysicsImpostor>;
  52197. /**
  52198. * Gets the impostor for a physics enabled object
  52199. * @param object defines the object impersonated by the impostor
  52200. * @returns the PhysicsImpostor or null if not found
  52201. */
  52202. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52203. /**
  52204. * Gets the impostor for a physics body object
  52205. * @param body defines physics body used by the impostor
  52206. * @returns the PhysicsImpostor or null if not found
  52207. */
  52208. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52209. /**
  52210. * Does a raycast in the physics world
  52211. * @param from when should the ray start?
  52212. * @param to when should the ray end?
  52213. * @returns PhysicsRaycastResult
  52214. */
  52215. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52216. }
  52217. }
  52218. declare module BABYLON {
  52219. /** @hidden */
  52220. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52221. private _useDeltaForWorldStep;
  52222. world: any;
  52223. name: string;
  52224. private _physicsMaterials;
  52225. private _fixedTimeStep;
  52226. private _cannonRaycastResult;
  52227. private _raycastResult;
  52228. private _physicsBodysToRemoveAfterStep;
  52229. BJSCANNON: any;
  52230. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52231. setGravity(gravity: Vector3): void;
  52232. setTimeStep(timeStep: number): void;
  52233. getTimeStep(): number;
  52234. executeStep(delta: number): void;
  52235. private _removeMarkedPhysicsBodiesFromWorld;
  52236. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52237. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52238. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52239. private _processChildMeshes;
  52240. removePhysicsBody(impostor: PhysicsImpostor): void;
  52241. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52242. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52243. private _addMaterial;
  52244. private _checkWithEpsilon;
  52245. private _createShape;
  52246. private _createHeightmap;
  52247. private _minus90X;
  52248. private _plus90X;
  52249. private _tmpPosition;
  52250. private _tmpDeltaPosition;
  52251. private _tmpUnityRotation;
  52252. private _updatePhysicsBodyTransformation;
  52253. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52254. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52255. isSupported(): boolean;
  52256. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52257. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52258. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52259. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52260. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52261. getBodyMass(impostor: PhysicsImpostor): number;
  52262. getBodyFriction(impostor: PhysicsImpostor): number;
  52263. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52264. getBodyRestitution(impostor: PhysicsImpostor): number;
  52265. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52266. sleepBody(impostor: PhysicsImpostor): void;
  52267. wakeUpBody(impostor: PhysicsImpostor): void;
  52268. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52269. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52270. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52271. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52272. getRadius(impostor: PhysicsImpostor): number;
  52273. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52274. dispose(): void;
  52275. private _extendNamespace;
  52276. /**
  52277. * Does a raycast in the physics world
  52278. * @param from when should the ray start?
  52279. * @param to when should the ray end?
  52280. * @returns PhysicsRaycastResult
  52281. */
  52282. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52283. }
  52284. }
  52285. declare module BABYLON {
  52286. /** @hidden */
  52287. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52288. world: any;
  52289. name: string;
  52290. BJSOIMO: any;
  52291. private _raycastResult;
  52292. constructor(iterations?: number, oimoInjection?: any);
  52293. setGravity(gravity: Vector3): void;
  52294. setTimeStep(timeStep: number): void;
  52295. getTimeStep(): number;
  52296. private _tmpImpostorsArray;
  52297. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52298. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52299. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52300. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52301. private _tmpPositionVector;
  52302. removePhysicsBody(impostor: PhysicsImpostor): void;
  52303. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52304. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52305. isSupported(): boolean;
  52306. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52307. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52308. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52309. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52310. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52311. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52312. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52313. getBodyMass(impostor: PhysicsImpostor): number;
  52314. getBodyFriction(impostor: PhysicsImpostor): number;
  52315. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52316. getBodyRestitution(impostor: PhysicsImpostor): number;
  52317. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52318. sleepBody(impostor: PhysicsImpostor): void;
  52319. wakeUpBody(impostor: PhysicsImpostor): void;
  52320. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52321. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52322. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52323. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52324. getRadius(impostor: PhysicsImpostor): number;
  52325. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52326. dispose(): void;
  52327. /**
  52328. * Does a raycast in the physics world
  52329. * @param from when should the ray start?
  52330. * @param to when should the ray end?
  52331. * @returns PhysicsRaycastResult
  52332. */
  52333. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52334. }
  52335. }
  52336. declare module BABYLON {
  52337. /**
  52338. * Class containing static functions to help procedurally build meshes
  52339. */
  52340. export class RibbonBuilder {
  52341. /**
  52342. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52343. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52344. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52345. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52346. * * 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
  52347. * * 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
  52348. * * 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
  52349. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52350. * * 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
  52351. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52352. * * 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
  52353. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52354. * * 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
  52355. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52357. * @param name defines the name of the mesh
  52358. * @param options defines the options used to create the mesh
  52359. * @param scene defines the hosting scene
  52360. * @returns the ribbon mesh
  52361. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52362. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52363. */
  52364. static CreateRibbon(name: string, options: {
  52365. pathArray: Vector3[][];
  52366. closeArray?: boolean;
  52367. closePath?: boolean;
  52368. offset?: number;
  52369. updatable?: boolean;
  52370. sideOrientation?: number;
  52371. frontUVs?: Vector4;
  52372. backUVs?: Vector4;
  52373. instance?: Mesh;
  52374. invertUV?: boolean;
  52375. uvs?: Vector2[];
  52376. colors?: Color4[];
  52377. }, scene?: Nullable<Scene>): Mesh;
  52378. }
  52379. }
  52380. declare module BABYLON {
  52381. /**
  52382. * Class containing static functions to help procedurally build meshes
  52383. */
  52384. export class ShapeBuilder {
  52385. /**
  52386. * 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.
  52387. * * 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.
  52388. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52389. * * 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.
  52390. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52391. * * 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
  52392. * * 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
  52393. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52395. * * 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
  52396. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52398. * @param name defines the name of the mesh
  52399. * @param options defines the options used to create the mesh
  52400. * @param scene defines the hosting scene
  52401. * @returns the extruded shape mesh
  52402. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52403. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52404. */
  52405. static ExtrudeShape(name: string, options: {
  52406. shape: Vector3[];
  52407. path: Vector3[];
  52408. scale?: number;
  52409. rotation?: number;
  52410. cap?: number;
  52411. updatable?: boolean;
  52412. sideOrientation?: number;
  52413. frontUVs?: Vector4;
  52414. backUVs?: Vector4;
  52415. instance?: Mesh;
  52416. invertUV?: boolean;
  52417. }, scene?: Nullable<Scene>): Mesh;
  52418. /**
  52419. * Creates an custom extruded shape mesh.
  52420. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52421. * * 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.
  52422. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52423. * * 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
  52424. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52425. * * 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
  52426. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52427. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52428. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52429. * * 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
  52430. * * 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
  52431. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52433. * * 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
  52434. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52436. * @param name defines the name of the mesh
  52437. * @param options defines the options used to create the mesh
  52438. * @param scene defines the hosting scene
  52439. * @returns the custom extruded shape mesh
  52440. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52441. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52442. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52443. */
  52444. static ExtrudeShapeCustom(name: string, options: {
  52445. shape: Vector3[];
  52446. path: Vector3[];
  52447. scaleFunction?: any;
  52448. rotationFunction?: any;
  52449. ribbonCloseArray?: boolean;
  52450. ribbonClosePath?: boolean;
  52451. cap?: number;
  52452. updatable?: boolean;
  52453. sideOrientation?: number;
  52454. frontUVs?: Vector4;
  52455. backUVs?: Vector4;
  52456. instance?: Mesh;
  52457. invertUV?: boolean;
  52458. }, scene?: Nullable<Scene>): Mesh;
  52459. private static _ExtrudeShapeGeneric;
  52460. }
  52461. }
  52462. declare module BABYLON {
  52463. /**
  52464. * AmmoJS Physics plugin
  52465. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52466. * @see https://github.com/kripken/ammo.js/
  52467. */
  52468. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52469. private _useDeltaForWorldStep;
  52470. /**
  52471. * Reference to the Ammo library
  52472. */
  52473. bjsAMMO: any;
  52474. /**
  52475. * Created ammoJS world which physics bodies are added to
  52476. */
  52477. world: any;
  52478. /**
  52479. * Name of the plugin
  52480. */
  52481. name: string;
  52482. private _timeStep;
  52483. private _fixedTimeStep;
  52484. private _maxSteps;
  52485. private _tmpQuaternion;
  52486. private _tmpAmmoTransform;
  52487. private _tmpAmmoQuaternion;
  52488. private _tmpAmmoConcreteContactResultCallback;
  52489. private _collisionConfiguration;
  52490. private _dispatcher;
  52491. private _overlappingPairCache;
  52492. private _solver;
  52493. private _softBodySolver;
  52494. private _tmpAmmoVectorA;
  52495. private _tmpAmmoVectorB;
  52496. private _tmpAmmoVectorC;
  52497. private _tmpAmmoVectorD;
  52498. private _tmpContactCallbackResult;
  52499. private _tmpAmmoVectorRCA;
  52500. private _tmpAmmoVectorRCB;
  52501. private _raycastResult;
  52502. private static readonly DISABLE_COLLISION_FLAG;
  52503. private static readonly KINEMATIC_FLAG;
  52504. private static readonly DISABLE_DEACTIVATION_FLAG;
  52505. /**
  52506. * Initializes the ammoJS plugin
  52507. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52508. * @param ammoInjection can be used to inject your own ammo reference
  52509. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  52510. */
  52511. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  52512. /**
  52513. * Sets the gravity of the physics world (m/(s^2))
  52514. * @param gravity Gravity to set
  52515. */
  52516. setGravity(gravity: Vector3): void;
  52517. /**
  52518. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52519. * @param timeStep timestep to use in seconds
  52520. */
  52521. setTimeStep(timeStep: number): void;
  52522. /**
  52523. * 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)
  52524. * @param fixedTimeStep fixedTimeStep to use in seconds
  52525. */
  52526. setFixedTimeStep(fixedTimeStep: number): void;
  52527. /**
  52528. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52529. * @param maxSteps the maximum number of steps by the physics engine per frame
  52530. */
  52531. setMaxSteps(maxSteps: number): void;
  52532. /**
  52533. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52534. * @returns the current timestep in seconds
  52535. */
  52536. getTimeStep(): number;
  52537. /**
  52538. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  52539. */
  52540. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  52541. private _isImpostorInContact;
  52542. private _isImpostorPairInContact;
  52543. private _stepSimulation;
  52544. /**
  52545. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52546. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52547. * After the step the babylon meshes are set to the position of the physics imposters
  52548. * @param delta amount of time to step forward
  52549. * @param impostors array of imposters to update before/after the step
  52550. */
  52551. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52552. /**
  52553. * Update babylon mesh to match physics world object
  52554. * @param impostor imposter to match
  52555. */
  52556. private _afterSoftStep;
  52557. /**
  52558. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52559. * @param impostor imposter to match
  52560. */
  52561. private _ropeStep;
  52562. /**
  52563. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52564. * @param impostor imposter to match
  52565. */
  52566. private _softbodyOrClothStep;
  52567. private _tmpVector;
  52568. private _tmpMatrix;
  52569. /**
  52570. * Applies an impulse on the imposter
  52571. * @param impostor imposter to apply impulse to
  52572. * @param force amount of force to be applied to the imposter
  52573. * @param contactPoint the location to apply the impulse on the imposter
  52574. */
  52575. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52576. /**
  52577. * Applies a force on the imposter
  52578. * @param impostor imposter to apply force
  52579. * @param force amount of force to be applied to the imposter
  52580. * @param contactPoint the location to apply the force on the imposter
  52581. */
  52582. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52583. /**
  52584. * Creates a physics body using the plugin
  52585. * @param impostor the imposter to create the physics body on
  52586. */
  52587. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52588. /**
  52589. * Removes the physics body from the imposter and disposes of the body's memory
  52590. * @param impostor imposter to remove the physics body from
  52591. */
  52592. removePhysicsBody(impostor: PhysicsImpostor): void;
  52593. /**
  52594. * Generates a joint
  52595. * @param impostorJoint the imposter joint to create the joint with
  52596. */
  52597. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52598. /**
  52599. * Removes a joint
  52600. * @param impostorJoint the imposter joint to remove the joint from
  52601. */
  52602. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52603. private _addMeshVerts;
  52604. /**
  52605. * Initialise the soft body vertices to match its object's (mesh) vertices
  52606. * Softbody vertices (nodes) are in world space and to match this
  52607. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  52608. * @param impostor to create the softbody for
  52609. */
  52610. private _softVertexData;
  52611. /**
  52612. * Create an impostor's soft body
  52613. * @param impostor to create the softbody for
  52614. */
  52615. private _createSoftbody;
  52616. /**
  52617. * Create cloth for an impostor
  52618. * @param impostor to create the softbody for
  52619. */
  52620. private _createCloth;
  52621. /**
  52622. * Create rope for an impostor
  52623. * @param impostor to create the softbody for
  52624. */
  52625. private _createRope;
  52626. /**
  52627. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  52628. * @param impostor to create the custom physics shape for
  52629. */
  52630. private _createCustom;
  52631. private _addHullVerts;
  52632. private _createShape;
  52633. /**
  52634. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52635. * @param impostor imposter containing the physics body and babylon object
  52636. */
  52637. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52638. /**
  52639. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52640. * @param impostor imposter containing the physics body and babylon object
  52641. * @param newPosition new position
  52642. * @param newRotation new rotation
  52643. */
  52644. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52645. /**
  52646. * If this plugin is supported
  52647. * @returns true if its supported
  52648. */
  52649. isSupported(): boolean;
  52650. /**
  52651. * Sets the linear velocity of the physics body
  52652. * @param impostor imposter to set the velocity on
  52653. * @param velocity velocity to set
  52654. */
  52655. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52656. /**
  52657. * Sets the angular velocity of the physics body
  52658. * @param impostor imposter to set the velocity on
  52659. * @param velocity velocity to set
  52660. */
  52661. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52662. /**
  52663. * gets the linear velocity
  52664. * @param impostor imposter to get linear velocity from
  52665. * @returns linear velocity
  52666. */
  52667. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52668. /**
  52669. * gets the angular velocity
  52670. * @param impostor imposter to get angular velocity from
  52671. * @returns angular velocity
  52672. */
  52673. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52674. /**
  52675. * Sets the mass of physics body
  52676. * @param impostor imposter to set the mass on
  52677. * @param mass mass to set
  52678. */
  52679. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52680. /**
  52681. * Gets the mass of the physics body
  52682. * @param impostor imposter to get the mass from
  52683. * @returns mass
  52684. */
  52685. getBodyMass(impostor: PhysicsImpostor): number;
  52686. /**
  52687. * Gets friction of the impostor
  52688. * @param impostor impostor to get friction from
  52689. * @returns friction value
  52690. */
  52691. getBodyFriction(impostor: PhysicsImpostor): number;
  52692. /**
  52693. * Sets friction of the impostor
  52694. * @param impostor impostor to set friction on
  52695. * @param friction friction value
  52696. */
  52697. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52698. /**
  52699. * Gets restitution of the impostor
  52700. * @param impostor impostor to get restitution from
  52701. * @returns restitution value
  52702. */
  52703. getBodyRestitution(impostor: PhysicsImpostor): number;
  52704. /**
  52705. * Sets resitution of the impostor
  52706. * @param impostor impostor to set resitution on
  52707. * @param restitution resitution value
  52708. */
  52709. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52710. /**
  52711. * Gets pressure inside the impostor
  52712. * @param impostor impostor to get pressure from
  52713. * @returns pressure value
  52714. */
  52715. getBodyPressure(impostor: PhysicsImpostor): number;
  52716. /**
  52717. * Sets pressure inside a soft body impostor
  52718. * Cloth and rope must remain 0 pressure
  52719. * @param impostor impostor to set pressure on
  52720. * @param pressure pressure value
  52721. */
  52722. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  52723. /**
  52724. * Gets stiffness of the impostor
  52725. * @param impostor impostor to get stiffness from
  52726. * @returns pressure value
  52727. */
  52728. getBodyStiffness(impostor: PhysicsImpostor): number;
  52729. /**
  52730. * Sets stiffness of the impostor
  52731. * @param impostor impostor to set stiffness on
  52732. * @param stiffness stiffness value from 0 to 1
  52733. */
  52734. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  52735. /**
  52736. * Gets velocityIterations of the impostor
  52737. * @param impostor impostor to get velocity iterations from
  52738. * @returns velocityIterations value
  52739. */
  52740. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  52741. /**
  52742. * Sets velocityIterations of the impostor
  52743. * @param impostor impostor to set velocity iterations on
  52744. * @param velocityIterations velocityIterations value
  52745. */
  52746. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  52747. /**
  52748. * Gets positionIterations of the impostor
  52749. * @param impostor impostor to get position iterations from
  52750. * @returns positionIterations value
  52751. */
  52752. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  52753. /**
  52754. * Sets positionIterations of the impostor
  52755. * @param impostor impostor to set position on
  52756. * @param positionIterations positionIterations value
  52757. */
  52758. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  52759. /**
  52760. * Append an anchor to a cloth object
  52761. * @param impostor is the cloth impostor to add anchor to
  52762. * @param otherImpostor is the rigid impostor to anchor to
  52763. * @param width ratio across width from 0 to 1
  52764. * @param height ratio up height from 0 to 1
  52765. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  52766. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52767. */
  52768. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52769. /**
  52770. * Append an hook to a rope object
  52771. * @param impostor is the rope impostor to add hook to
  52772. * @param otherImpostor is the rigid impostor to hook to
  52773. * @param length ratio along the rope from 0 to 1
  52774. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  52775. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52776. */
  52777. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52778. /**
  52779. * Sleeps the physics body and stops it from being active
  52780. * @param impostor impostor to sleep
  52781. */
  52782. sleepBody(impostor: PhysicsImpostor): void;
  52783. /**
  52784. * Activates the physics body
  52785. * @param impostor impostor to activate
  52786. */
  52787. wakeUpBody(impostor: PhysicsImpostor): void;
  52788. /**
  52789. * Updates the distance parameters of the joint
  52790. * @param joint joint to update
  52791. * @param maxDistance maximum distance of the joint
  52792. * @param minDistance minimum distance of the joint
  52793. */
  52794. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52795. /**
  52796. * Sets a motor on the joint
  52797. * @param joint joint to set motor on
  52798. * @param speed speed of the motor
  52799. * @param maxForce maximum force of the motor
  52800. * @param motorIndex index of the motor
  52801. */
  52802. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52803. /**
  52804. * Sets the motors limit
  52805. * @param joint joint to set limit on
  52806. * @param upperLimit upper limit
  52807. * @param lowerLimit lower limit
  52808. */
  52809. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52810. /**
  52811. * Syncs the position and rotation of a mesh with the impostor
  52812. * @param mesh mesh to sync
  52813. * @param impostor impostor to update the mesh with
  52814. */
  52815. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52816. /**
  52817. * Gets the radius of the impostor
  52818. * @param impostor impostor to get radius from
  52819. * @returns the radius
  52820. */
  52821. getRadius(impostor: PhysicsImpostor): number;
  52822. /**
  52823. * Gets the box size of the impostor
  52824. * @param impostor impostor to get box size from
  52825. * @param result the resulting box size
  52826. */
  52827. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52828. /**
  52829. * Disposes of the impostor
  52830. */
  52831. dispose(): void;
  52832. /**
  52833. * Does a raycast in the physics world
  52834. * @param from when should the ray start?
  52835. * @param to when should the ray end?
  52836. * @returns PhysicsRaycastResult
  52837. */
  52838. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52839. }
  52840. }
  52841. declare module BABYLON {
  52842. interface AbstractScene {
  52843. /**
  52844. * The list of reflection probes added to the scene
  52845. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52846. */
  52847. reflectionProbes: Array<ReflectionProbe>;
  52848. /**
  52849. * Removes the given reflection probe from this scene.
  52850. * @param toRemove The reflection probe to remove
  52851. * @returns The index of the removed reflection probe
  52852. */
  52853. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52854. /**
  52855. * Adds the given reflection probe to this scene.
  52856. * @param newReflectionProbe The reflection probe to add
  52857. */
  52858. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52859. }
  52860. /**
  52861. * Class used to generate realtime reflection / refraction cube textures
  52862. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52863. */
  52864. export class ReflectionProbe {
  52865. /** defines the name of the probe */
  52866. name: string;
  52867. private _scene;
  52868. private _renderTargetTexture;
  52869. private _projectionMatrix;
  52870. private _viewMatrix;
  52871. private _target;
  52872. private _add;
  52873. private _attachedMesh;
  52874. private _invertYAxis;
  52875. /** Gets or sets probe position (center of the cube map) */
  52876. position: Vector3;
  52877. /**
  52878. * Creates a new reflection probe
  52879. * @param name defines the name of the probe
  52880. * @param size defines the texture resolution (for each face)
  52881. * @param scene defines the hosting scene
  52882. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  52883. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  52884. */
  52885. constructor(
  52886. /** defines the name of the probe */
  52887. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  52888. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  52889. samples: number;
  52890. /** Gets or sets the refresh rate to use (on every frame by default) */
  52891. refreshRate: number;
  52892. /**
  52893. * Gets the hosting scene
  52894. * @returns a Scene
  52895. */
  52896. getScene(): Scene;
  52897. /** Gets the internal CubeTexture used to render to */
  52898. readonly cubeTexture: RenderTargetTexture;
  52899. /** Gets the list of meshes to render */
  52900. readonly renderList: Nullable<AbstractMesh[]>;
  52901. /**
  52902. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52903. * @param mesh defines the mesh to attach to
  52904. */
  52905. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52906. /**
  52907. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52908. * @param renderingGroupId The rendering group id corresponding to its index
  52909. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52910. */
  52911. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52912. /**
  52913. * Clean all associated resources
  52914. */
  52915. dispose(): void;
  52916. /**
  52917. * Converts the reflection probe information to a readable string for debug purpose.
  52918. * @param fullDetails Supports for multiple levels of logging within scene loading
  52919. * @returns the human readable reflection probe info
  52920. */
  52921. toString(fullDetails?: boolean): string;
  52922. /**
  52923. * Get the class name of the relfection probe.
  52924. * @returns "ReflectionProbe"
  52925. */
  52926. getClassName(): string;
  52927. /**
  52928. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  52929. * @returns The JSON representation of the texture
  52930. */
  52931. serialize(): any;
  52932. /**
  52933. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  52934. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  52935. * @param scene Define the scene the parsed reflection probe should be instantiated in
  52936. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  52937. * @returns The parsed reflection probe if successful
  52938. */
  52939. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52940. }
  52941. }
  52942. declare module BABYLON {
  52943. /** @hidden */
  52944. export var _BabylonLoaderRegistered: boolean;
  52945. /**
  52946. * Helps setting up some configuration for the babylon file loader.
  52947. */
  52948. export class BabylonFileLoaderConfiguration {
  52949. /**
  52950. * The loader does not allow injecting custom physix engine into the plugins.
  52951. * Unfortunately in ES6, we need to manually inject them into the plugin.
  52952. * So you could set this variable to your engine import to make it work.
  52953. */
  52954. static LoaderInjectedPhysicsEngine: any;
  52955. }
  52956. }
  52957. declare module BABYLON {
  52958. /**
  52959. * The Physically based simple base material of BJS.
  52960. *
  52961. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52962. * It is used as the base class for both the specGloss and metalRough conventions.
  52963. */
  52964. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52965. /**
  52966. * Number of Simultaneous lights allowed on the material.
  52967. */
  52968. maxSimultaneousLights: number;
  52969. /**
  52970. * If sets to true, disables all the lights affecting the material.
  52971. */
  52972. disableLighting: boolean;
  52973. /**
  52974. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52975. */
  52976. environmentTexture: BaseTexture;
  52977. /**
  52978. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52979. */
  52980. invertNormalMapX: boolean;
  52981. /**
  52982. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52983. */
  52984. invertNormalMapY: boolean;
  52985. /**
  52986. * Normal map used in the model.
  52987. */
  52988. normalTexture: BaseTexture;
  52989. /**
  52990. * Emissivie color used to self-illuminate the model.
  52991. */
  52992. emissiveColor: Color3;
  52993. /**
  52994. * Emissivie texture used to self-illuminate the model.
  52995. */
  52996. emissiveTexture: BaseTexture;
  52997. /**
  52998. * Occlusion Channel Strenght.
  52999. */
  53000. occlusionStrength: number;
  53001. /**
  53002. * Occlusion Texture of the material (adding extra occlusion effects).
  53003. */
  53004. occlusionTexture: BaseTexture;
  53005. /**
  53006. * Defines the alpha limits in alpha test mode.
  53007. */
  53008. alphaCutOff: number;
  53009. /**
  53010. * Gets the current double sided mode.
  53011. */
  53012. /**
  53013. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53014. */
  53015. doubleSided: boolean;
  53016. /**
  53017. * Stores the pre-calculated light information of a mesh in a texture.
  53018. */
  53019. lightmapTexture: BaseTexture;
  53020. /**
  53021. * If true, the light map contains occlusion information instead of lighting info.
  53022. */
  53023. useLightmapAsShadowmap: boolean;
  53024. /**
  53025. * Instantiates a new PBRMaterial instance.
  53026. *
  53027. * @param name The material name
  53028. * @param scene The scene the material will be use in.
  53029. */
  53030. constructor(name: string, scene: Scene);
  53031. getClassName(): string;
  53032. }
  53033. }
  53034. declare module BABYLON {
  53035. /**
  53036. * The PBR material of BJS following the metal roughness convention.
  53037. *
  53038. * This fits to the PBR convention in the GLTF definition:
  53039. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53040. */
  53041. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53042. /**
  53043. * The base color has two different interpretations depending on the value of metalness.
  53044. * When the material is a metal, the base color is the specific measured reflectance value
  53045. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53046. * of the material.
  53047. */
  53048. baseColor: Color3;
  53049. /**
  53050. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53051. * well as opacity information in the alpha channel.
  53052. */
  53053. baseTexture: BaseTexture;
  53054. /**
  53055. * Specifies the metallic scalar value of the material.
  53056. * Can also be used to scale the metalness values of the metallic texture.
  53057. */
  53058. metallic: number;
  53059. /**
  53060. * Specifies the roughness scalar value of the material.
  53061. * Can also be used to scale the roughness values of the metallic texture.
  53062. */
  53063. roughness: number;
  53064. /**
  53065. * Texture containing both the metallic value in the B channel and the
  53066. * roughness value in the G channel to keep better precision.
  53067. */
  53068. metallicRoughnessTexture: BaseTexture;
  53069. /**
  53070. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53071. *
  53072. * @param name The material name
  53073. * @param scene The scene the material will be use in.
  53074. */
  53075. constructor(name: string, scene: Scene);
  53076. /**
  53077. * Return the currrent class name of the material.
  53078. */
  53079. getClassName(): string;
  53080. /**
  53081. * Makes a duplicate of the current material.
  53082. * @param name - name to use for the new material.
  53083. */
  53084. clone(name: string): PBRMetallicRoughnessMaterial;
  53085. /**
  53086. * Serialize the material to a parsable JSON object.
  53087. */
  53088. serialize(): any;
  53089. /**
  53090. * Parses a JSON object correponding to the serialize function.
  53091. */
  53092. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53093. }
  53094. }
  53095. declare module BABYLON {
  53096. /**
  53097. * The PBR material of BJS following the specular glossiness convention.
  53098. *
  53099. * This fits to the PBR convention in the GLTF definition:
  53100. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53101. */
  53102. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53103. /**
  53104. * Specifies the diffuse color of the material.
  53105. */
  53106. diffuseColor: Color3;
  53107. /**
  53108. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53109. * channel.
  53110. */
  53111. diffuseTexture: BaseTexture;
  53112. /**
  53113. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53114. */
  53115. specularColor: Color3;
  53116. /**
  53117. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53118. */
  53119. glossiness: number;
  53120. /**
  53121. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53122. */
  53123. specularGlossinessTexture: BaseTexture;
  53124. /**
  53125. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53126. *
  53127. * @param name The material name
  53128. * @param scene The scene the material will be use in.
  53129. */
  53130. constructor(name: string, scene: Scene);
  53131. /**
  53132. * Return the currrent class name of the material.
  53133. */
  53134. getClassName(): string;
  53135. /**
  53136. * Makes a duplicate of the current material.
  53137. * @param name - name to use for the new material.
  53138. */
  53139. clone(name: string): PBRSpecularGlossinessMaterial;
  53140. /**
  53141. * Serialize the material to a parsable JSON object.
  53142. */
  53143. serialize(): any;
  53144. /**
  53145. * Parses a JSON object correponding to the serialize function.
  53146. */
  53147. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53148. }
  53149. }
  53150. declare module BABYLON {
  53151. /**
  53152. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53153. * It can help converting any input color in a desired output one. This can then be used to create effects
  53154. * from sepia, black and white to sixties or futuristic rendering...
  53155. *
  53156. * The only supported format is currently 3dl.
  53157. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53158. */
  53159. export class ColorGradingTexture extends BaseTexture {
  53160. /**
  53161. * The current texture matrix. (will always be identity in color grading texture)
  53162. */
  53163. private _textureMatrix;
  53164. /**
  53165. * The texture URL.
  53166. */
  53167. url: string;
  53168. /**
  53169. * Empty line regex stored for GC.
  53170. */
  53171. private static _noneEmptyLineRegex;
  53172. private _engine;
  53173. /**
  53174. * Instantiates a ColorGradingTexture from the following parameters.
  53175. *
  53176. * @param url The location of the color gradind data (currently only supporting 3dl)
  53177. * @param scene The scene the texture will be used in
  53178. */
  53179. constructor(url: string, scene: Scene);
  53180. /**
  53181. * Returns the texture matrix used in most of the material.
  53182. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53183. */
  53184. getTextureMatrix(): Matrix;
  53185. /**
  53186. * Occurs when the file being loaded is a .3dl LUT file.
  53187. */
  53188. private load3dlTexture;
  53189. /**
  53190. * Starts the loading process of the texture.
  53191. */
  53192. private loadTexture;
  53193. /**
  53194. * Clones the color gradind texture.
  53195. */
  53196. clone(): ColorGradingTexture;
  53197. /**
  53198. * Called during delayed load for textures.
  53199. */
  53200. delayLoad(): void;
  53201. /**
  53202. * Parses a color grading texture serialized by Babylon.
  53203. * @param parsedTexture The texture information being parsedTexture
  53204. * @param scene The scene to load the texture in
  53205. * @param rootUrl The root url of the data assets to load
  53206. * @return A color gradind texture
  53207. */
  53208. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53209. /**
  53210. * Serializes the LUT texture to json format.
  53211. */
  53212. serialize(): any;
  53213. }
  53214. }
  53215. declare module BABYLON {
  53216. /**
  53217. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53218. */
  53219. export class EquiRectangularCubeTexture extends BaseTexture {
  53220. /** The six faces of the cube. */
  53221. private static _FacesMapping;
  53222. private _noMipmap;
  53223. private _onLoad;
  53224. private _onError;
  53225. /** The size of the cubemap. */
  53226. private _size;
  53227. /** The buffer of the image. */
  53228. private _buffer;
  53229. /** The width of the input image. */
  53230. private _width;
  53231. /** The height of the input image. */
  53232. private _height;
  53233. /** The URL to the image. */
  53234. url: string;
  53235. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53236. coordinatesMode: number;
  53237. /**
  53238. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53239. * @param url The location of the image
  53240. * @param scene The scene the texture will be used in
  53241. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53242. * @param noMipmap Forces to not generate the mipmap if true
  53243. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53244. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53245. * @param onLoad — defines a callback called when texture is loaded
  53246. * @param onError — defines a callback called if there is an error
  53247. */
  53248. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53249. /**
  53250. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53251. */
  53252. private loadImage;
  53253. /**
  53254. * Convert the image buffer into a cubemap and create a CubeTexture.
  53255. */
  53256. private loadTexture;
  53257. /**
  53258. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53259. * @param buffer The ArrayBuffer that should be converted.
  53260. * @returns The buffer as Float32Array.
  53261. */
  53262. private getFloat32ArrayFromArrayBuffer;
  53263. /**
  53264. * Get the current class name of the texture useful for serialization or dynamic coding.
  53265. * @returns "EquiRectangularCubeTexture"
  53266. */
  53267. getClassName(): string;
  53268. /**
  53269. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53270. * @returns A clone of the current EquiRectangularCubeTexture.
  53271. */
  53272. clone(): EquiRectangularCubeTexture;
  53273. }
  53274. }
  53275. declare module BABYLON {
  53276. /**
  53277. * Based on jsTGALoader - Javascript loader for TGA file
  53278. * By Vincent Thibault
  53279. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53280. */
  53281. export class TGATools {
  53282. private static _TYPE_INDEXED;
  53283. private static _TYPE_RGB;
  53284. private static _TYPE_GREY;
  53285. private static _TYPE_RLE_INDEXED;
  53286. private static _TYPE_RLE_RGB;
  53287. private static _TYPE_RLE_GREY;
  53288. private static _ORIGIN_MASK;
  53289. private static _ORIGIN_SHIFT;
  53290. private static _ORIGIN_BL;
  53291. private static _ORIGIN_BR;
  53292. private static _ORIGIN_UL;
  53293. private static _ORIGIN_UR;
  53294. /**
  53295. * Gets the header of a TGA file
  53296. * @param data defines the TGA data
  53297. * @returns the header
  53298. */
  53299. static GetTGAHeader(data: Uint8Array): any;
  53300. /**
  53301. * Uploads TGA content to a Babylon Texture
  53302. * @hidden
  53303. */
  53304. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53305. /** @hidden */
  53306. 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;
  53307. /** @hidden */
  53308. 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;
  53309. /** @hidden */
  53310. 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;
  53311. /** @hidden */
  53312. 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;
  53313. /** @hidden */
  53314. 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;
  53315. /** @hidden */
  53316. 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;
  53317. }
  53318. }
  53319. declare module BABYLON {
  53320. /**
  53321. * Implementation of the TGA Texture Loader.
  53322. * @hidden
  53323. */
  53324. export class _TGATextureLoader implements IInternalTextureLoader {
  53325. /**
  53326. * Defines wether the loader supports cascade loading the different faces.
  53327. */
  53328. readonly supportCascades: boolean;
  53329. /**
  53330. * This returns if the loader support the current file information.
  53331. * @param extension defines the file extension of the file being loaded
  53332. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53333. * @param fallback defines the fallback internal texture if any
  53334. * @param isBase64 defines whether the texture is encoded as a base64
  53335. * @param isBuffer defines whether the texture data are stored as a buffer
  53336. * @returns true if the loader can load the specified file
  53337. */
  53338. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53339. /**
  53340. * Transform the url before loading if required.
  53341. * @param rootUrl the url of the texture
  53342. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53343. * @returns the transformed texture
  53344. */
  53345. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53346. /**
  53347. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53348. * @param rootUrl the url of the texture
  53349. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53350. * @returns the fallback texture
  53351. */
  53352. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53353. /**
  53354. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53355. * @param data contains the texture data
  53356. * @param texture defines the BabylonJS internal texture
  53357. * @param createPolynomials will be true if polynomials have been requested
  53358. * @param onLoad defines the callback to trigger once the texture is ready
  53359. * @param onError defines the callback to trigger in case of error
  53360. */
  53361. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53362. /**
  53363. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53364. * @param data contains the texture data
  53365. * @param texture defines the BabylonJS internal texture
  53366. * @param callback defines the method to call once ready to upload
  53367. */
  53368. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53369. }
  53370. }
  53371. declare module BABYLON {
  53372. /**
  53373. * Info about the .basis files
  53374. */
  53375. class BasisFileInfo {
  53376. /**
  53377. * If the file has alpha
  53378. */
  53379. hasAlpha: boolean;
  53380. /**
  53381. * Info about each image of the basis file
  53382. */
  53383. images: Array<{
  53384. levels: Array<{
  53385. width: number;
  53386. height: number;
  53387. transcodedPixels: ArrayBufferView;
  53388. }>;
  53389. }>;
  53390. }
  53391. /**
  53392. * Result of transcoding a basis file
  53393. */
  53394. class TranscodeResult {
  53395. /**
  53396. * Info about the .basis file
  53397. */
  53398. fileInfo: BasisFileInfo;
  53399. /**
  53400. * Format to use when loading the file
  53401. */
  53402. format: number;
  53403. }
  53404. /**
  53405. * Configuration options for the Basis transcoder
  53406. */
  53407. export class BasisTranscodeConfiguration {
  53408. /**
  53409. * Supported compression formats used to determine the supported output format of the transcoder
  53410. */
  53411. supportedCompressionFormats?: {
  53412. /**
  53413. * etc1 compression format
  53414. */
  53415. etc1?: boolean;
  53416. /**
  53417. * s3tc compression format
  53418. */
  53419. s3tc?: boolean;
  53420. /**
  53421. * pvrtc compression format
  53422. */
  53423. pvrtc?: boolean;
  53424. /**
  53425. * etc2 compression format
  53426. */
  53427. etc2?: boolean;
  53428. };
  53429. /**
  53430. * If mipmap levels should be loaded for transcoded images (Default: true)
  53431. */
  53432. loadMipmapLevels?: boolean;
  53433. /**
  53434. * Index of a single image to load (Default: all images)
  53435. */
  53436. loadSingleImage?: number;
  53437. }
  53438. /**
  53439. * Used to load .Basis files
  53440. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53441. */
  53442. export class BasisTools {
  53443. private static _IgnoreSupportedFormats;
  53444. /**
  53445. * URL to use when loading the basis transcoder
  53446. */
  53447. static JSModuleURL: string;
  53448. /**
  53449. * URL to use when loading the wasm module for the transcoder
  53450. */
  53451. static WasmModuleURL: string;
  53452. /**
  53453. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53454. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53455. * @returns internal format corresponding to the Basis format
  53456. */
  53457. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53458. private static _WorkerPromise;
  53459. private static _Worker;
  53460. private static _actionId;
  53461. private static _CreateWorkerAsync;
  53462. /**
  53463. * Transcodes a loaded image file to compressed pixel data
  53464. * @param imageData image data to transcode
  53465. * @param config configuration options for the transcoding
  53466. * @returns a promise resulting in the transcoded image
  53467. */
  53468. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53469. /**
  53470. * Loads a texture from the transcode result
  53471. * @param texture texture load to
  53472. * @param transcodeResult the result of transcoding the basis file to load from
  53473. */
  53474. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  53475. }
  53476. }
  53477. declare module BABYLON {
  53478. /**
  53479. * Loader for .basis file format
  53480. */
  53481. export class _BasisTextureLoader implements IInternalTextureLoader {
  53482. /**
  53483. * Defines whether the loader supports cascade loading the different faces.
  53484. */
  53485. readonly supportCascades: boolean;
  53486. /**
  53487. * This returns if the loader support the current file information.
  53488. * @param extension defines the file extension of the file being loaded
  53489. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53490. * @param fallback defines the fallback internal texture if any
  53491. * @param isBase64 defines whether the texture is encoded as a base64
  53492. * @param isBuffer defines whether the texture data are stored as a buffer
  53493. * @returns true if the loader can load the specified file
  53494. */
  53495. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53496. /**
  53497. * Transform the url before loading if required.
  53498. * @param rootUrl the url of the texture
  53499. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53500. * @returns the transformed texture
  53501. */
  53502. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53503. /**
  53504. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53505. * @param rootUrl the url of the texture
  53506. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53507. * @returns the fallback texture
  53508. */
  53509. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53510. /**
  53511. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  53512. * @param data contains the texture data
  53513. * @param texture defines the BabylonJS internal texture
  53514. * @param createPolynomials will be true if polynomials have been requested
  53515. * @param onLoad defines the callback to trigger once the texture is ready
  53516. * @param onError defines the callback to trigger in case of error
  53517. */
  53518. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53519. /**
  53520. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53521. * @param data contains the texture data
  53522. * @param texture defines the BabylonJS internal texture
  53523. * @param callback defines the method to call once ready to upload
  53524. */
  53525. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53526. }
  53527. }
  53528. declare module BABYLON {
  53529. /**
  53530. * 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.
  53531. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53532. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53533. */
  53534. export class CustomProceduralTexture extends ProceduralTexture {
  53535. private _animate;
  53536. private _time;
  53537. private _config;
  53538. private _texturePath;
  53539. /**
  53540. * Instantiates a new Custom Procedural Texture.
  53541. * 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.
  53542. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53543. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53544. * @param name Define the name of the texture
  53545. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53546. * @param size Define the size of the texture to create
  53547. * @param scene Define the scene the texture belongs to
  53548. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53549. * @param generateMipMaps Define if the texture should creates mip maps or not
  53550. */
  53551. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53552. private _loadJson;
  53553. /**
  53554. * Is the texture ready to be used ? (rendered at least once)
  53555. * @returns true if ready, otherwise, false.
  53556. */
  53557. isReady(): boolean;
  53558. /**
  53559. * Render the texture to its associated render target.
  53560. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53561. */
  53562. render(useCameraPostProcess?: boolean): void;
  53563. /**
  53564. * Update the list of dependant textures samplers in the shader.
  53565. */
  53566. updateTextures(): void;
  53567. /**
  53568. * Update the uniform values of the procedural texture in the shader.
  53569. */
  53570. updateShaderUniforms(): void;
  53571. /**
  53572. * Define if the texture animates or not.
  53573. */
  53574. animate: boolean;
  53575. }
  53576. }
  53577. declare module BABYLON {
  53578. /** @hidden */
  53579. export var noisePixelShader: {
  53580. name: string;
  53581. shader: string;
  53582. };
  53583. }
  53584. declare module BABYLON {
  53585. /**
  53586. * Class used to generate noise procedural textures
  53587. */
  53588. export class NoiseProceduralTexture extends ProceduralTexture {
  53589. private _time;
  53590. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53591. brightness: number;
  53592. /** Defines the number of octaves to process */
  53593. octaves: number;
  53594. /** Defines the level of persistence (0.8 by default) */
  53595. persistence: number;
  53596. /** Gets or sets animation speed factor (default is 1) */
  53597. animationSpeedFactor: number;
  53598. /**
  53599. * Creates a new NoiseProceduralTexture
  53600. * @param name defines the name fo the texture
  53601. * @param size defines the size of the texture (default is 256)
  53602. * @param scene defines the hosting scene
  53603. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53604. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53605. */
  53606. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53607. private _updateShaderUniforms;
  53608. protected _getDefines(): string;
  53609. /** Generate the current state of the procedural texture */
  53610. render(useCameraPostProcess?: boolean): void;
  53611. /**
  53612. * Serializes this noise procedural texture
  53613. * @returns a serialized noise procedural texture object
  53614. */
  53615. serialize(): any;
  53616. /**
  53617. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53618. * @param parsedTexture defines parsed texture data
  53619. * @param scene defines the current scene
  53620. * @param rootUrl defines the root URL containing noise procedural texture information
  53621. * @returns a parsed NoiseProceduralTexture
  53622. */
  53623. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  53624. }
  53625. }
  53626. declare module BABYLON {
  53627. /**
  53628. * Raw cube texture where the raw buffers are passed in
  53629. */
  53630. export class RawCubeTexture extends CubeTexture {
  53631. /**
  53632. * Creates a cube texture where the raw buffers are passed in.
  53633. * @param scene defines the scene the texture is attached to
  53634. * @param data defines the array of data to use to create each face
  53635. * @param size defines the size of the textures
  53636. * @param format defines the format of the data
  53637. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  53638. * @param generateMipMaps defines if the engine should generate the mip levels
  53639. * @param invertY defines if data must be stored with Y axis inverted
  53640. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  53641. * @param compression defines the compression used (null by default)
  53642. */
  53643. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  53644. /**
  53645. * Updates the raw cube texture.
  53646. * @param data defines the data to store
  53647. * @param format defines the data format
  53648. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53649. * @param invertY defines if data must be stored with Y axis inverted
  53650. * @param compression defines the compression used (null by default)
  53651. * @param level defines which level of the texture to update
  53652. */
  53653. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  53654. /**
  53655. * Updates a raw cube texture with RGBD encoded data.
  53656. * @param data defines the array of data [mipmap][face] to use to create each face
  53657. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  53658. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53659. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53660. * @returns a promsie that resolves when the operation is complete
  53661. */
  53662. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  53663. /**
  53664. * Clones the raw cube texture.
  53665. * @return a new cube texture
  53666. */
  53667. clone(): CubeTexture;
  53668. /** @hidden */
  53669. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53670. }
  53671. }
  53672. declare module BABYLON {
  53673. /**
  53674. * Class used to store 3D textures containing user data
  53675. */
  53676. export class RawTexture3D extends Texture {
  53677. /** Gets or sets the texture format to use */
  53678. format: number;
  53679. private _engine;
  53680. /**
  53681. * Create a new RawTexture3D
  53682. * @param data defines the data of the texture
  53683. * @param width defines the width of the texture
  53684. * @param height defines the height of the texture
  53685. * @param depth defines the depth of the texture
  53686. * @param format defines the texture format to use
  53687. * @param scene defines the hosting scene
  53688. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53689. * @param invertY defines if texture must be stored with Y axis inverted
  53690. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53691. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53692. */
  53693. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53694. /** Gets or sets the texture format to use */
  53695. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53696. /**
  53697. * Update the texture with new data
  53698. * @param data defines the data to store in the texture
  53699. */
  53700. update(data: ArrayBufferView): void;
  53701. }
  53702. }
  53703. declare module BABYLON {
  53704. /**
  53705. * Class used to store 2D array textures containing user data
  53706. */
  53707. export class RawTexture2DArray extends Texture {
  53708. /** Gets or sets the texture format to use */
  53709. format: number;
  53710. private _engine;
  53711. /**
  53712. * Create a new RawTexture2DArray
  53713. * @param data defines the data of the texture
  53714. * @param width defines the width of the texture
  53715. * @param height defines the height of the texture
  53716. * @param depth defines the number of layers of the texture
  53717. * @param format defines the texture format to use
  53718. * @param scene defines the hosting scene
  53719. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53720. * @param invertY defines if texture must be stored with Y axis inverted
  53721. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53722. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53723. */
  53724. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53725. /** Gets or sets the texture format to use */
  53726. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53727. /**
  53728. * Update the texture with new data
  53729. * @param data defines the data to store in the texture
  53730. */
  53731. update(data: ArrayBufferView): void;
  53732. }
  53733. }
  53734. declare module BABYLON {
  53735. /**
  53736. * Creates a refraction texture used by refraction channel of the standard material.
  53737. * It is like a mirror but to see through a material.
  53738. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53739. */
  53740. export class RefractionTexture extends RenderTargetTexture {
  53741. /**
  53742. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  53743. * 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.
  53744. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53745. */
  53746. refractionPlane: Plane;
  53747. /**
  53748. * Define how deep under the surface we should see.
  53749. */
  53750. depth: number;
  53751. /**
  53752. * Creates a refraction texture used by refraction channel of the standard material.
  53753. * It is like a mirror but to see through a material.
  53754. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53755. * @param name Define the texture name
  53756. * @param size Define the size of the underlying texture
  53757. * @param scene Define the scene the refraction belongs to
  53758. * @param generateMipMaps Define if we need to generate mips level for the refraction
  53759. */
  53760. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  53761. /**
  53762. * Clone the refraction texture.
  53763. * @returns the cloned texture
  53764. */
  53765. clone(): RefractionTexture;
  53766. /**
  53767. * Serialize the texture to a JSON representation you could use in Parse later on
  53768. * @returns the serialized JSON representation
  53769. */
  53770. serialize(): any;
  53771. }
  53772. }
  53773. declare module BABYLON {
  53774. /**
  53775. * Defines the options related to the creation of an HtmlElementTexture
  53776. */
  53777. export interface IHtmlElementTextureOptions {
  53778. /**
  53779. * Defines wether mip maps should be created or not.
  53780. */
  53781. generateMipMaps?: boolean;
  53782. /**
  53783. * Defines the sampling mode of the texture.
  53784. */
  53785. samplingMode?: number;
  53786. /**
  53787. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  53788. */
  53789. engine: Nullable<ThinEngine>;
  53790. /**
  53791. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  53792. */
  53793. scene: Nullable<Scene>;
  53794. }
  53795. /**
  53796. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  53797. * To be as efficient as possible depending on your constraints nothing aside the first upload
  53798. * is automatically managed.
  53799. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  53800. * in your application.
  53801. *
  53802. * As the update is not automatic, you need to call them manually.
  53803. */
  53804. export class HtmlElementTexture extends BaseTexture {
  53805. /**
  53806. * The texture URL.
  53807. */
  53808. element: HTMLVideoElement | HTMLCanvasElement;
  53809. private static readonly DefaultOptions;
  53810. private _textureMatrix;
  53811. private _engine;
  53812. private _isVideo;
  53813. private _generateMipMaps;
  53814. private _samplingMode;
  53815. /**
  53816. * Instantiates a HtmlElementTexture from the following parameters.
  53817. *
  53818. * @param name Defines the name of the texture
  53819. * @param element Defines the video or canvas the texture is filled with
  53820. * @param options Defines the other none mandatory texture creation options
  53821. */
  53822. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  53823. private _createInternalTexture;
  53824. /**
  53825. * Returns the texture matrix used in most of the material.
  53826. */
  53827. getTextureMatrix(): Matrix;
  53828. /**
  53829. * Updates the content of the texture.
  53830. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  53831. */
  53832. update(invertY?: Nullable<boolean>): void;
  53833. }
  53834. }
  53835. declare module BABYLON {
  53836. /**
  53837. * Enum used to define the target of a block
  53838. */
  53839. export enum NodeMaterialBlockTargets {
  53840. /** Vertex shader */
  53841. Vertex = 1,
  53842. /** Fragment shader */
  53843. Fragment = 2,
  53844. /** Neutral */
  53845. Neutral = 4,
  53846. /** Vertex and Fragment */
  53847. VertexAndFragment = 3
  53848. }
  53849. }
  53850. declare module BABYLON {
  53851. /**
  53852. * Defines the kind of connection point for node based material
  53853. */
  53854. export enum NodeMaterialBlockConnectionPointTypes {
  53855. /** Float */
  53856. Float = 1,
  53857. /** Int */
  53858. Int = 2,
  53859. /** Vector2 */
  53860. Vector2 = 4,
  53861. /** Vector3 */
  53862. Vector3 = 8,
  53863. /** Vector4 */
  53864. Vector4 = 16,
  53865. /** Color3 */
  53866. Color3 = 32,
  53867. /** Color4 */
  53868. Color4 = 64,
  53869. /** Matrix */
  53870. Matrix = 128,
  53871. /** Detect type based on connection */
  53872. AutoDetect = 1024,
  53873. /** Output type that will be defined by input type */
  53874. BasedOnInput = 2048
  53875. }
  53876. }
  53877. declare module BABYLON {
  53878. /**
  53879. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  53880. */
  53881. export enum NodeMaterialBlockConnectionPointMode {
  53882. /** Value is an uniform */
  53883. Uniform = 0,
  53884. /** Value is a mesh attribute */
  53885. Attribute = 1,
  53886. /** Value is a varying between vertex and fragment shaders */
  53887. Varying = 2,
  53888. /** Mode is undefined */
  53889. Undefined = 3
  53890. }
  53891. }
  53892. declare module BABYLON {
  53893. /**
  53894. * Enum used to define system values e.g. values automatically provided by the system
  53895. */
  53896. export enum NodeMaterialSystemValues {
  53897. /** World */
  53898. World = 1,
  53899. /** View */
  53900. View = 2,
  53901. /** Projection */
  53902. Projection = 3,
  53903. /** ViewProjection */
  53904. ViewProjection = 4,
  53905. /** WorldView */
  53906. WorldView = 5,
  53907. /** WorldViewProjection */
  53908. WorldViewProjection = 6,
  53909. /** CameraPosition */
  53910. CameraPosition = 7,
  53911. /** Fog Color */
  53912. FogColor = 8,
  53913. /** Delta time */
  53914. DeltaTime = 9
  53915. }
  53916. }
  53917. declare module BABYLON {
  53918. /**
  53919. * Root class for all node material optimizers
  53920. */
  53921. export class NodeMaterialOptimizer {
  53922. /**
  53923. * Function used to optimize a NodeMaterial graph
  53924. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53925. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53926. */
  53927. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53928. }
  53929. }
  53930. declare module BABYLON {
  53931. /**
  53932. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  53933. */
  53934. export class TransformBlock extends NodeMaterialBlock {
  53935. /**
  53936. * Defines the value to use to complement W value to transform it to a Vector4
  53937. */
  53938. complementW: number;
  53939. /**
  53940. * Defines the value to use to complement z value to transform it to a Vector4
  53941. */
  53942. complementZ: number;
  53943. /**
  53944. * Creates a new TransformBlock
  53945. * @param name defines the block name
  53946. */
  53947. constructor(name: string);
  53948. /**
  53949. * Gets the current class name
  53950. * @returns the class name
  53951. */
  53952. getClassName(): string;
  53953. /**
  53954. * Gets the vector input
  53955. */
  53956. readonly vector: NodeMaterialConnectionPoint;
  53957. /**
  53958. * Gets the output component
  53959. */
  53960. readonly output: NodeMaterialConnectionPoint;
  53961. /**
  53962. * Gets the matrix transform input
  53963. */
  53964. readonly transform: NodeMaterialConnectionPoint;
  53965. protected _buildBlock(state: NodeMaterialBuildState): this;
  53966. serialize(): any;
  53967. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53968. protected _dumpPropertiesCode(): string;
  53969. }
  53970. }
  53971. declare module BABYLON {
  53972. /**
  53973. * Block used to output the vertex position
  53974. */
  53975. export class VertexOutputBlock extends NodeMaterialBlock {
  53976. /**
  53977. * Creates a new VertexOutputBlock
  53978. * @param name defines the block name
  53979. */
  53980. constructor(name: string);
  53981. /**
  53982. * Gets the current class name
  53983. * @returns the class name
  53984. */
  53985. getClassName(): string;
  53986. /**
  53987. * Gets the vector input component
  53988. */
  53989. readonly vector: NodeMaterialConnectionPoint;
  53990. protected _buildBlock(state: NodeMaterialBuildState): this;
  53991. }
  53992. }
  53993. declare module BABYLON {
  53994. /**
  53995. * Block used to output the final color
  53996. */
  53997. export class FragmentOutputBlock extends NodeMaterialBlock {
  53998. /**
  53999. * Create a new FragmentOutputBlock
  54000. * @param name defines the block name
  54001. */
  54002. constructor(name: string);
  54003. /**
  54004. * Gets the current class name
  54005. * @returns the class name
  54006. */
  54007. getClassName(): string;
  54008. /**
  54009. * Gets the rgba input component
  54010. */
  54011. readonly rgba: NodeMaterialConnectionPoint;
  54012. /**
  54013. * Gets the rgb input component
  54014. */
  54015. readonly rgb: NodeMaterialConnectionPoint;
  54016. /**
  54017. * Gets the a input component
  54018. */
  54019. readonly a: NodeMaterialConnectionPoint;
  54020. protected _buildBlock(state: NodeMaterialBuildState): this;
  54021. }
  54022. }
  54023. declare module BABYLON {
  54024. /**
  54025. * Block used to read a reflection texture from a sampler
  54026. */
  54027. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54028. private _define3DName;
  54029. private _defineCubicName;
  54030. private _defineExplicitName;
  54031. private _defineProjectionName;
  54032. private _defineLocalCubicName;
  54033. private _defineSphericalName;
  54034. private _definePlanarName;
  54035. private _defineEquirectangularName;
  54036. private _defineMirroredEquirectangularFixedName;
  54037. private _defineEquirectangularFixedName;
  54038. private _defineSkyboxName;
  54039. private _cubeSamplerName;
  54040. private _2DSamplerName;
  54041. private _positionUVWName;
  54042. private _directionWName;
  54043. private _reflectionCoordsName;
  54044. private _reflection2DCoordsName;
  54045. private _reflectionColorName;
  54046. private _reflectionMatrixName;
  54047. /**
  54048. * Gets or sets the texture associated with the node
  54049. */
  54050. texture: Nullable<BaseTexture>;
  54051. /**
  54052. * Create a new TextureBlock
  54053. * @param name defines the block name
  54054. */
  54055. constructor(name: string);
  54056. /**
  54057. * Gets the current class name
  54058. * @returns the class name
  54059. */
  54060. getClassName(): string;
  54061. /**
  54062. * Gets the world position input component
  54063. */
  54064. readonly position: NodeMaterialConnectionPoint;
  54065. /**
  54066. * Gets the world position input component
  54067. */
  54068. readonly worldPosition: NodeMaterialConnectionPoint;
  54069. /**
  54070. * Gets the world normal input component
  54071. */
  54072. readonly worldNormal: NodeMaterialConnectionPoint;
  54073. /**
  54074. * Gets the world input component
  54075. */
  54076. readonly world: NodeMaterialConnectionPoint;
  54077. /**
  54078. * Gets the camera (or eye) position component
  54079. */
  54080. readonly cameraPosition: NodeMaterialConnectionPoint;
  54081. /**
  54082. * Gets the view input component
  54083. */
  54084. readonly view: NodeMaterialConnectionPoint;
  54085. /**
  54086. * Gets the rgb output component
  54087. */
  54088. readonly rgb: NodeMaterialConnectionPoint;
  54089. /**
  54090. * Gets the r output component
  54091. */
  54092. readonly r: NodeMaterialConnectionPoint;
  54093. /**
  54094. * Gets the g output component
  54095. */
  54096. readonly g: NodeMaterialConnectionPoint;
  54097. /**
  54098. * Gets the b output component
  54099. */
  54100. readonly b: NodeMaterialConnectionPoint;
  54101. autoConfigure(material: NodeMaterial): void;
  54102. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54103. isReady(): boolean;
  54104. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54105. private _injectVertexCode;
  54106. private _writeOutput;
  54107. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54108. protected _dumpPropertiesCode(): string;
  54109. serialize(): any;
  54110. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54111. }
  54112. }
  54113. declare module BABYLON {
  54114. /**
  54115. * Interface used to configure the node material editor
  54116. */
  54117. export interface INodeMaterialEditorOptions {
  54118. /** Define the URl to load node editor script */
  54119. editorURL?: string;
  54120. }
  54121. /** @hidden */
  54122. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54123. /** BONES */
  54124. NUM_BONE_INFLUENCERS: number;
  54125. BonesPerMesh: number;
  54126. BONETEXTURE: boolean;
  54127. /** MORPH TARGETS */
  54128. MORPHTARGETS: boolean;
  54129. MORPHTARGETS_NORMAL: boolean;
  54130. MORPHTARGETS_TANGENT: boolean;
  54131. MORPHTARGETS_UV: boolean;
  54132. NUM_MORPH_INFLUENCERS: number;
  54133. /** IMAGE PROCESSING */
  54134. IMAGEPROCESSING: boolean;
  54135. VIGNETTE: boolean;
  54136. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54137. VIGNETTEBLENDMODEOPAQUE: boolean;
  54138. TONEMAPPING: boolean;
  54139. TONEMAPPING_ACES: boolean;
  54140. CONTRAST: boolean;
  54141. EXPOSURE: boolean;
  54142. COLORCURVES: boolean;
  54143. COLORGRADING: boolean;
  54144. COLORGRADING3D: boolean;
  54145. SAMPLER3DGREENDEPTH: boolean;
  54146. SAMPLER3DBGRMAP: boolean;
  54147. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54148. /** MISC. */
  54149. BUMPDIRECTUV: number;
  54150. constructor();
  54151. setValue(name: string, value: boolean): void;
  54152. }
  54153. /**
  54154. * Class used to configure NodeMaterial
  54155. */
  54156. export interface INodeMaterialOptions {
  54157. /**
  54158. * Defines if blocks should emit comments
  54159. */
  54160. emitComments: boolean;
  54161. }
  54162. /**
  54163. * Class used to create a node based material built by assembling shader blocks
  54164. */
  54165. export class NodeMaterial extends PushMaterial {
  54166. private static _BuildIdGenerator;
  54167. private _options;
  54168. private _vertexCompilationState;
  54169. private _fragmentCompilationState;
  54170. private _sharedData;
  54171. private _buildId;
  54172. private _buildWasSuccessful;
  54173. private _cachedWorldViewMatrix;
  54174. private _cachedWorldViewProjectionMatrix;
  54175. private _optimizers;
  54176. private _animationFrame;
  54177. /** Define the URl to load node editor script */
  54178. static EditorURL: string;
  54179. private BJSNODEMATERIALEDITOR;
  54180. /** Get the inspector from bundle or global */
  54181. private _getGlobalNodeMaterialEditor;
  54182. /**
  54183. * Gets or sets data used by visual editor
  54184. * @see https://nme.babylonjs.com
  54185. */
  54186. editorData: any;
  54187. /**
  54188. * 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)
  54189. */
  54190. ignoreAlpha: boolean;
  54191. /**
  54192. * Defines the maximum number of lights that can be used in the material
  54193. */
  54194. maxSimultaneousLights: number;
  54195. /**
  54196. * Observable raised when the material is built
  54197. */
  54198. onBuildObservable: Observable<NodeMaterial>;
  54199. /**
  54200. * Gets or sets the root nodes of the material vertex shader
  54201. */
  54202. _vertexOutputNodes: NodeMaterialBlock[];
  54203. /**
  54204. * Gets or sets the root nodes of the material fragment (pixel) shader
  54205. */
  54206. _fragmentOutputNodes: NodeMaterialBlock[];
  54207. /** Gets or sets options to control the node material overall behavior */
  54208. options: INodeMaterialOptions;
  54209. /**
  54210. * Default configuration related to image processing available in the standard Material.
  54211. */
  54212. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54213. /**
  54214. * Gets the image processing configuration used either in this material.
  54215. */
  54216. /**
  54217. * Sets the Default image processing configuration used either in the this material.
  54218. *
  54219. * If sets to null, the scene one is in use.
  54220. */
  54221. imageProcessingConfiguration: ImageProcessingConfiguration;
  54222. /**
  54223. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54224. */
  54225. attachedBlocks: NodeMaterialBlock[];
  54226. /**
  54227. * Create a new node based material
  54228. * @param name defines the material name
  54229. * @param scene defines the hosting scene
  54230. * @param options defines creation option
  54231. */
  54232. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54233. /**
  54234. * Gets the current class name of the material e.g. "NodeMaterial"
  54235. * @returns the class name
  54236. */
  54237. getClassName(): string;
  54238. /**
  54239. * Keep track of the image processing observer to allow dispose and replace.
  54240. */
  54241. private _imageProcessingObserver;
  54242. /**
  54243. * Attaches a new image processing configuration to the Standard Material.
  54244. * @param configuration
  54245. */
  54246. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54247. /**
  54248. * Get a block by its name
  54249. * @param name defines the name of the block to retrieve
  54250. * @returns the required block or null if not found
  54251. */
  54252. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  54253. /**
  54254. * Get a block by its name
  54255. * @param predicate defines the predicate used to find the good candidate
  54256. * @returns the required block or null if not found
  54257. */
  54258. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  54259. /**
  54260. * Get an input block by its name
  54261. * @param predicate defines the predicate used to find the good candidate
  54262. * @returns the required input block or null if not found
  54263. */
  54264. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  54265. /**
  54266. * Gets the list of input blocks attached to this material
  54267. * @returns an array of InputBlocks
  54268. */
  54269. getInputBlocks(): InputBlock[];
  54270. /**
  54271. * Adds a new optimizer to the list of optimizers
  54272. * @param optimizer defines the optimizers to add
  54273. * @returns the current material
  54274. */
  54275. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54276. /**
  54277. * Remove an optimizer from the list of optimizers
  54278. * @param optimizer defines the optimizers to remove
  54279. * @returns the current material
  54280. */
  54281. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54282. /**
  54283. * Add a new block to the list of output nodes
  54284. * @param node defines the node to add
  54285. * @returns the current material
  54286. */
  54287. addOutputNode(node: NodeMaterialBlock): this;
  54288. /**
  54289. * Remove a block from the list of root nodes
  54290. * @param node defines the node to remove
  54291. * @returns the current material
  54292. */
  54293. removeOutputNode(node: NodeMaterialBlock): this;
  54294. private _addVertexOutputNode;
  54295. private _removeVertexOutputNode;
  54296. private _addFragmentOutputNode;
  54297. private _removeFragmentOutputNode;
  54298. /**
  54299. * Specifies if the material will require alpha blending
  54300. * @returns a boolean specifying if alpha blending is needed
  54301. */
  54302. needAlphaBlending(): boolean;
  54303. /**
  54304. * Specifies if this material should be rendered in alpha test mode
  54305. * @returns a boolean specifying if an alpha test is needed.
  54306. */
  54307. needAlphaTesting(): boolean;
  54308. private _initializeBlock;
  54309. private _resetDualBlocks;
  54310. /**
  54311. * Remove a block from the current node material
  54312. * @param block defines the block to remove
  54313. */
  54314. removeBlock(block: NodeMaterialBlock): void;
  54315. /**
  54316. * Build the material and generates the inner effect
  54317. * @param verbose defines if the build should log activity
  54318. */
  54319. build(verbose?: boolean): void;
  54320. /**
  54321. * Runs an otpimization phase to try to improve the shader code
  54322. */
  54323. optimize(): void;
  54324. private _prepareDefinesForAttributes;
  54325. /**
  54326. * Get if the submesh is ready to be used and all its information available.
  54327. * Child classes can use it to update shaders
  54328. * @param mesh defines the mesh to check
  54329. * @param subMesh defines which submesh to check
  54330. * @param useInstances specifies that instances should be used
  54331. * @returns a boolean indicating that the submesh is ready or not
  54332. */
  54333. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54334. /**
  54335. * Get a string representing the shaders built by the current node graph
  54336. */
  54337. readonly compiledShaders: string;
  54338. /**
  54339. * Binds the world matrix to the material
  54340. * @param world defines the world transformation matrix
  54341. */
  54342. bindOnlyWorldMatrix(world: Matrix): void;
  54343. /**
  54344. * Binds the submesh to this material by preparing the effect and shader to draw
  54345. * @param world defines the world transformation matrix
  54346. * @param mesh defines the mesh containing the submesh
  54347. * @param subMesh defines the submesh to bind the material to
  54348. */
  54349. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54350. /**
  54351. * Gets the active textures from the material
  54352. * @returns an array of textures
  54353. */
  54354. getActiveTextures(): BaseTexture[];
  54355. /**
  54356. * Gets the list of texture blocks
  54357. * @returns an array of texture blocks
  54358. */
  54359. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  54360. /**
  54361. * Specifies if the material uses a texture
  54362. * @param texture defines the texture to check against the material
  54363. * @returns a boolean specifying if the material uses the texture
  54364. */
  54365. hasTexture(texture: BaseTexture): boolean;
  54366. /**
  54367. * Disposes the material
  54368. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54369. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54370. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54371. */
  54372. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54373. /** Creates the node editor window. */
  54374. private _createNodeEditor;
  54375. /**
  54376. * Launch the node material editor
  54377. * @param config Define the configuration of the editor
  54378. * @return a promise fulfilled when the node editor is visible
  54379. */
  54380. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54381. /**
  54382. * Clear the current material
  54383. */
  54384. clear(): void;
  54385. /**
  54386. * Clear the current material and set it to a default state
  54387. */
  54388. setToDefault(): void;
  54389. /**
  54390. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  54391. * @param url defines the url to load from
  54392. * @returns a promise that will fullfil when the material is fully loaded
  54393. */
  54394. loadAsync(url: string): Promise<void>;
  54395. private _gatherBlocks;
  54396. /**
  54397. * Generate a string containing the code declaration required to create an equivalent of this material
  54398. * @returns a string
  54399. */
  54400. generateCode(): string;
  54401. /**
  54402. * Serializes this material in a JSON representation
  54403. * @returns the serialized material object
  54404. */
  54405. serialize(): any;
  54406. private _restoreConnections;
  54407. /**
  54408. * Clear the current graph and load a new one from a serialization object
  54409. * @param source defines the JSON representation of the material
  54410. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54411. */
  54412. loadFromSerialization(source: any, rootUrl?: string): void;
  54413. /**
  54414. * Creates a node material from parsed material data
  54415. * @param source defines the JSON representation of the material
  54416. * @param scene defines the hosting scene
  54417. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54418. * @returns a new node material
  54419. */
  54420. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  54421. /**
  54422. * Creates a new node material set to default basic configuration
  54423. * @param name defines the name of the material
  54424. * @param scene defines the hosting scene
  54425. * @returns a new NodeMaterial
  54426. */
  54427. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  54428. }
  54429. }
  54430. declare module BABYLON {
  54431. /**
  54432. * Block used to read a texture from a sampler
  54433. */
  54434. export class TextureBlock extends NodeMaterialBlock {
  54435. private _defineName;
  54436. private _linearDefineName;
  54437. private _tempTextureRead;
  54438. private _samplerName;
  54439. private _transformedUVName;
  54440. private _textureTransformName;
  54441. private _textureInfoName;
  54442. private _mainUVName;
  54443. private _mainUVDefineName;
  54444. /**
  54445. * Gets or sets the texture associated with the node
  54446. */
  54447. texture: Nullable<Texture>;
  54448. /**
  54449. * Create a new TextureBlock
  54450. * @param name defines the block name
  54451. */
  54452. constructor(name: string);
  54453. /**
  54454. * Gets the current class name
  54455. * @returns the class name
  54456. */
  54457. getClassName(): string;
  54458. /**
  54459. * Gets the uv input component
  54460. */
  54461. readonly uv: NodeMaterialConnectionPoint;
  54462. /**
  54463. * Gets the rgba output component
  54464. */
  54465. readonly rgba: NodeMaterialConnectionPoint;
  54466. /**
  54467. * Gets the rgb output component
  54468. */
  54469. readonly rgb: NodeMaterialConnectionPoint;
  54470. /**
  54471. * Gets the r output component
  54472. */
  54473. readonly r: NodeMaterialConnectionPoint;
  54474. /**
  54475. * Gets the g output component
  54476. */
  54477. readonly g: NodeMaterialConnectionPoint;
  54478. /**
  54479. * Gets the b output component
  54480. */
  54481. readonly b: NodeMaterialConnectionPoint;
  54482. /**
  54483. * Gets the a output component
  54484. */
  54485. readonly a: NodeMaterialConnectionPoint;
  54486. readonly target: NodeMaterialBlockTargets;
  54487. autoConfigure(material: NodeMaterial): void;
  54488. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54489. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54490. private _getTextureBase;
  54491. isReady(): boolean;
  54492. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54493. private readonly _isMixed;
  54494. private _injectVertexCode;
  54495. private _writeTextureRead;
  54496. private _writeOutput;
  54497. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54498. protected _dumpPropertiesCode(): string;
  54499. serialize(): any;
  54500. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54501. }
  54502. }
  54503. declare module BABYLON {
  54504. /**
  54505. * Class used to store shared data between 2 NodeMaterialBuildState
  54506. */
  54507. export class NodeMaterialBuildStateSharedData {
  54508. /**
  54509. * Gets the list of emitted varyings
  54510. */
  54511. temps: string[];
  54512. /**
  54513. * Gets the list of emitted varyings
  54514. */
  54515. varyings: string[];
  54516. /**
  54517. * Gets the varying declaration string
  54518. */
  54519. varyingDeclaration: string;
  54520. /**
  54521. * Input blocks
  54522. */
  54523. inputBlocks: InputBlock[];
  54524. /**
  54525. * Input blocks
  54526. */
  54527. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  54528. /**
  54529. * Bindable blocks (Blocks that need to set data to the effect)
  54530. */
  54531. bindableBlocks: NodeMaterialBlock[];
  54532. /**
  54533. * List of blocks that can provide a compilation fallback
  54534. */
  54535. blocksWithFallbacks: NodeMaterialBlock[];
  54536. /**
  54537. * List of blocks that can provide a define update
  54538. */
  54539. blocksWithDefines: NodeMaterialBlock[];
  54540. /**
  54541. * List of blocks that can provide a repeatable content
  54542. */
  54543. repeatableContentBlocks: NodeMaterialBlock[];
  54544. /**
  54545. * List of blocks that can provide a dynamic list of uniforms
  54546. */
  54547. dynamicUniformBlocks: NodeMaterialBlock[];
  54548. /**
  54549. * List of blocks that can block the isReady function for the material
  54550. */
  54551. blockingBlocks: NodeMaterialBlock[];
  54552. /**
  54553. * Gets the list of animated inputs
  54554. */
  54555. animatedInputs: InputBlock[];
  54556. /**
  54557. * Build Id used to avoid multiple recompilations
  54558. */
  54559. buildId: number;
  54560. /** List of emitted variables */
  54561. variableNames: {
  54562. [key: string]: number;
  54563. };
  54564. /** List of emitted defines */
  54565. defineNames: {
  54566. [key: string]: number;
  54567. };
  54568. /** Should emit comments? */
  54569. emitComments: boolean;
  54570. /** Emit build activity */
  54571. verbose: boolean;
  54572. /** Gets or sets the hosting scene */
  54573. scene: Scene;
  54574. /**
  54575. * Gets the compilation hints emitted at compilation time
  54576. */
  54577. hints: {
  54578. needWorldViewMatrix: boolean;
  54579. needWorldViewProjectionMatrix: boolean;
  54580. needAlphaBlending: boolean;
  54581. needAlphaTesting: boolean;
  54582. };
  54583. /**
  54584. * List of compilation checks
  54585. */
  54586. checks: {
  54587. emitVertex: boolean;
  54588. emitFragment: boolean;
  54589. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  54590. };
  54591. /** Creates a new shared data */
  54592. constructor();
  54593. /**
  54594. * Emits console errors and exceptions if there is a failing check
  54595. */
  54596. emitErrors(): void;
  54597. }
  54598. }
  54599. declare module BABYLON {
  54600. /**
  54601. * Class used to store node based material build state
  54602. */
  54603. export class NodeMaterialBuildState {
  54604. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  54605. supportUniformBuffers: boolean;
  54606. /**
  54607. * Gets the list of emitted attributes
  54608. */
  54609. attributes: string[];
  54610. /**
  54611. * Gets the list of emitted uniforms
  54612. */
  54613. uniforms: string[];
  54614. /**
  54615. * Gets the list of emitted constants
  54616. */
  54617. constants: string[];
  54618. /**
  54619. * Gets the list of emitted samplers
  54620. */
  54621. samplers: string[];
  54622. /**
  54623. * Gets the list of emitted functions
  54624. */
  54625. functions: {
  54626. [key: string]: string;
  54627. };
  54628. /**
  54629. * Gets the list of emitted extensions
  54630. */
  54631. extensions: {
  54632. [key: string]: string;
  54633. };
  54634. /**
  54635. * Gets the target of the compilation state
  54636. */
  54637. target: NodeMaterialBlockTargets;
  54638. /**
  54639. * Gets the list of emitted counters
  54640. */
  54641. counters: {
  54642. [key: string]: number;
  54643. };
  54644. /**
  54645. * Shared data between multiple NodeMaterialBuildState instances
  54646. */
  54647. sharedData: NodeMaterialBuildStateSharedData;
  54648. /** @hidden */
  54649. _vertexState: NodeMaterialBuildState;
  54650. /** @hidden */
  54651. _attributeDeclaration: string;
  54652. /** @hidden */
  54653. _uniformDeclaration: string;
  54654. /** @hidden */
  54655. _constantDeclaration: string;
  54656. /** @hidden */
  54657. _samplerDeclaration: string;
  54658. /** @hidden */
  54659. _varyingTransfer: string;
  54660. private _repeatableContentAnchorIndex;
  54661. /** @hidden */
  54662. _builtCompilationString: string;
  54663. /**
  54664. * Gets the emitted compilation strings
  54665. */
  54666. compilationString: string;
  54667. /**
  54668. * Finalize the compilation strings
  54669. * @param state defines the current compilation state
  54670. */
  54671. finalize(state: NodeMaterialBuildState): void;
  54672. /** @hidden */
  54673. readonly _repeatableContentAnchor: string;
  54674. /** @hidden */
  54675. _getFreeVariableName(prefix: string): string;
  54676. /** @hidden */
  54677. _getFreeDefineName(prefix: string): string;
  54678. /** @hidden */
  54679. _excludeVariableName(name: string): void;
  54680. /** @hidden */
  54681. _emit2DSampler(name: string): void;
  54682. /** @hidden */
  54683. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  54684. /** @hidden */
  54685. _emitExtension(name: string, extension: string): void;
  54686. /** @hidden */
  54687. _emitFunction(name: string, code: string, comments: string): void;
  54688. /** @hidden */
  54689. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  54690. replaceStrings?: {
  54691. search: RegExp;
  54692. replace: string;
  54693. }[];
  54694. repeatKey?: string;
  54695. }): string;
  54696. /** @hidden */
  54697. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  54698. repeatKey?: string;
  54699. removeAttributes?: boolean;
  54700. removeUniforms?: boolean;
  54701. removeVaryings?: boolean;
  54702. removeIfDef?: boolean;
  54703. replaceStrings?: {
  54704. search: RegExp;
  54705. replace: string;
  54706. }[];
  54707. }, storeKey?: string): void;
  54708. /** @hidden */
  54709. _registerTempVariable(name: string): boolean;
  54710. /** @hidden */
  54711. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  54712. /** @hidden */
  54713. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54714. /** @hidden */
  54715. _emitFloat(value: number): string;
  54716. }
  54717. }
  54718. declare module BABYLON {
  54719. /**
  54720. * Defines a block that can be used inside a node based material
  54721. */
  54722. export class NodeMaterialBlock {
  54723. private _buildId;
  54724. private _buildTarget;
  54725. private _target;
  54726. private _isFinalMerger;
  54727. private _isInput;
  54728. protected _isUnique: boolean;
  54729. /** @hidden */
  54730. _codeVariableName: string;
  54731. /** @hidden */
  54732. _inputs: NodeMaterialConnectionPoint[];
  54733. /** @hidden */
  54734. _outputs: NodeMaterialConnectionPoint[];
  54735. /** @hidden */
  54736. _preparationId: number;
  54737. /**
  54738. * Gets or sets the name of the block
  54739. */
  54740. name: string;
  54741. /**
  54742. * Gets or sets the unique id of the node
  54743. */
  54744. uniqueId: number;
  54745. /**
  54746. * Gets or sets the comments associated with this block
  54747. */
  54748. comments: string;
  54749. /**
  54750. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  54751. */
  54752. readonly isUnique: boolean;
  54753. /**
  54754. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  54755. */
  54756. readonly isFinalMerger: boolean;
  54757. /**
  54758. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  54759. */
  54760. readonly isInput: boolean;
  54761. /**
  54762. * Gets or sets the build Id
  54763. */
  54764. buildId: number;
  54765. /**
  54766. * Gets or sets the target of the block
  54767. */
  54768. target: NodeMaterialBlockTargets;
  54769. /**
  54770. * Gets the list of input points
  54771. */
  54772. readonly inputs: NodeMaterialConnectionPoint[];
  54773. /** Gets the list of output points */
  54774. readonly outputs: NodeMaterialConnectionPoint[];
  54775. /**
  54776. * Find an input by its name
  54777. * @param name defines the name of the input to look for
  54778. * @returns the input or null if not found
  54779. */
  54780. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54781. /**
  54782. * Find an output by its name
  54783. * @param name defines the name of the outputto look for
  54784. * @returns the output or null if not found
  54785. */
  54786. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54787. /**
  54788. * Creates a new NodeMaterialBlock
  54789. * @param name defines the block name
  54790. * @param target defines the target of that block (Vertex by default)
  54791. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  54792. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  54793. */
  54794. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  54795. /**
  54796. * Initialize the block and prepare the context for build
  54797. * @param state defines the state that will be used for the build
  54798. */
  54799. initialize(state: NodeMaterialBuildState): void;
  54800. /**
  54801. * Bind data to effect. Will only be called for blocks with isBindable === true
  54802. * @param effect defines the effect to bind data to
  54803. * @param nodeMaterial defines the hosting NodeMaterial
  54804. * @param mesh defines the mesh that will be rendered
  54805. */
  54806. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54807. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  54808. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  54809. protected _writeFloat(value: number): string;
  54810. /**
  54811. * Gets the current class name e.g. "NodeMaterialBlock"
  54812. * @returns the class name
  54813. */
  54814. getClassName(): string;
  54815. /**
  54816. * Register a new input. Must be called inside a block constructor
  54817. * @param name defines the connection point name
  54818. * @param type defines the connection point type
  54819. * @param isOptional defines a boolean indicating that this input can be omitted
  54820. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  54821. * @returns the current block
  54822. */
  54823. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  54824. /**
  54825. * Register a new output. Must be called inside a block constructor
  54826. * @param name defines the connection point name
  54827. * @param type defines the connection point type
  54828. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  54829. * @returns the current block
  54830. */
  54831. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  54832. /**
  54833. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  54834. * @param forOutput defines an optional connection point to check compatibility with
  54835. * @returns the first available input or null
  54836. */
  54837. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  54838. /**
  54839. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  54840. * @param forBlock defines an optional block to check compatibility with
  54841. * @returns the first available input or null
  54842. */
  54843. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  54844. /**
  54845. * Gets the sibling of the given output
  54846. * @param current defines the current output
  54847. * @returns the next output in the list or null
  54848. */
  54849. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  54850. /**
  54851. * Connect current block with another block
  54852. * @param other defines the block to connect with
  54853. * @param options define the various options to help pick the right connections
  54854. * @returns the current block
  54855. */
  54856. connectTo(other: NodeMaterialBlock, options?: {
  54857. input?: string;
  54858. output?: string;
  54859. outputSwizzle?: string;
  54860. }): this | undefined;
  54861. protected _buildBlock(state: NodeMaterialBuildState): void;
  54862. /**
  54863. * Add uniforms, samplers and uniform buffers at compilation time
  54864. * @param state defines the state to update
  54865. * @param nodeMaterial defines the node material requesting the update
  54866. * @param defines defines the material defines to update
  54867. * @param uniformBuffers defines the list of uniform buffer names
  54868. */
  54869. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  54870. /**
  54871. * Add potential fallbacks if shader compilation fails
  54872. * @param mesh defines the mesh to be rendered
  54873. * @param fallbacks defines the current prioritized list of fallbacks
  54874. */
  54875. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54876. /**
  54877. * Initialize defines for shader compilation
  54878. * @param mesh defines the mesh to be rendered
  54879. * @param nodeMaterial defines the node material requesting the update
  54880. * @param defines defines the material defines to update
  54881. * @param useInstances specifies that instances should be used
  54882. */
  54883. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54884. /**
  54885. * Update defines for shader compilation
  54886. * @param mesh defines the mesh to be rendered
  54887. * @param nodeMaterial defines the node material requesting the update
  54888. * @param defines defines the material defines to update
  54889. * @param useInstances specifies that instances should be used
  54890. */
  54891. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54892. /**
  54893. * Lets the block try to connect some inputs automatically
  54894. * @param material defines the hosting NodeMaterial
  54895. */
  54896. autoConfigure(material: NodeMaterial): void;
  54897. /**
  54898. * Function called when a block is declared as repeatable content generator
  54899. * @param vertexShaderState defines the current compilation state for the vertex shader
  54900. * @param fragmentShaderState defines the current compilation state for the fragment shader
  54901. * @param mesh defines the mesh to be rendered
  54902. * @param defines defines the material defines to update
  54903. */
  54904. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54905. /**
  54906. * Checks if the block is ready
  54907. * @param mesh defines the mesh to be rendered
  54908. * @param nodeMaterial defines the node material requesting the update
  54909. * @param defines defines the material defines to update
  54910. * @param useInstances specifies that instances should be used
  54911. * @returns true if the block is ready
  54912. */
  54913. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  54914. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  54915. private _processBuild;
  54916. /**
  54917. * Compile the current node and generate the shader code
  54918. * @param state defines the current compilation state (uniforms, samplers, current string)
  54919. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  54920. * @returns true if already built
  54921. */
  54922. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  54923. protected _inputRename(name: string): string;
  54924. protected _outputRename(name: string): string;
  54925. protected _dumpPropertiesCode(): string;
  54926. /** @hidden */
  54927. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  54928. /** @hidden */
  54929. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  54930. /**
  54931. * Clone the current block to a new identical block
  54932. * @param scene defines the hosting scene
  54933. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54934. * @returns a copy of the current block
  54935. */
  54936. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  54937. /**
  54938. * Serializes this block in a JSON representation
  54939. * @returns the serialized block object
  54940. */
  54941. serialize(): any;
  54942. /** @hidden */
  54943. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54944. /**
  54945. * Release resources
  54946. */
  54947. dispose(): void;
  54948. }
  54949. }
  54950. declare module BABYLON {
  54951. /**
  54952. * Enum defining the type of animations supported by InputBlock
  54953. */
  54954. export enum AnimatedInputBlockTypes {
  54955. /** No animation */
  54956. None = 0,
  54957. /** Time based animation. Will only work for floats */
  54958. Time = 1
  54959. }
  54960. }
  54961. declare module BABYLON {
  54962. /**
  54963. * Block used to expose an input value
  54964. */
  54965. export class InputBlock extends NodeMaterialBlock {
  54966. private _mode;
  54967. private _associatedVariableName;
  54968. private _storedValue;
  54969. private _valueCallback;
  54970. private _type;
  54971. private _animationType;
  54972. /** Gets or set a value used to limit the range of float values */
  54973. min: number;
  54974. /** Gets or set a value used to limit the range of float values */
  54975. max: number;
  54976. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  54977. matrixMode: number;
  54978. /** @hidden */
  54979. _systemValue: Nullable<NodeMaterialSystemValues>;
  54980. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  54981. visibleInInspector: boolean;
  54982. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  54983. isConstant: boolean;
  54984. /** Gets or sets the group to use to display this block in the Inspector */
  54985. groupInInspector: string;
  54986. /**
  54987. * Gets or sets the connection point type (default is float)
  54988. */
  54989. readonly type: NodeMaterialBlockConnectionPointTypes;
  54990. /**
  54991. * Creates a new InputBlock
  54992. * @param name defines the block name
  54993. * @param target defines the target of that block (Vertex by default)
  54994. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  54995. */
  54996. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  54997. /**
  54998. * Gets the output component
  54999. */
  55000. readonly output: NodeMaterialConnectionPoint;
  55001. /**
  55002. * Set the source of this connection point to a vertex attribute
  55003. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55004. * @returns the current connection point
  55005. */
  55006. setAsAttribute(attributeName?: string): InputBlock;
  55007. /**
  55008. * Set the source of this connection point to a system value
  55009. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  55010. * @returns the current connection point
  55011. */
  55012. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  55013. /**
  55014. * Gets or sets the value of that point.
  55015. * Please note that this value will be ignored if valueCallback is defined
  55016. */
  55017. value: any;
  55018. /**
  55019. * Gets or sets a callback used to get the value of that point.
  55020. * Please note that setting this value will force the connection point to ignore the value property
  55021. */
  55022. valueCallback: () => any;
  55023. /**
  55024. * Gets or sets the associated variable name in the shader
  55025. */
  55026. associatedVariableName: string;
  55027. /** Gets or sets the type of animation applied to the input */
  55028. animationType: AnimatedInputBlockTypes;
  55029. /**
  55030. * Gets a boolean indicating that this connection point not defined yet
  55031. */
  55032. readonly isUndefined: boolean;
  55033. /**
  55034. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55035. * In this case the connection point name must be the name of the uniform to use.
  55036. * Can only be set on inputs
  55037. */
  55038. isUniform: boolean;
  55039. /**
  55040. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55041. * In this case the connection point name must be the name of the attribute to use
  55042. * Can only be set on inputs
  55043. */
  55044. isAttribute: boolean;
  55045. /**
  55046. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55047. * Can only be set on exit points
  55048. */
  55049. isVarying: boolean;
  55050. /**
  55051. * Gets a boolean indicating that the current connection point is a system value
  55052. */
  55053. readonly isSystemValue: boolean;
  55054. /**
  55055. * Gets or sets the current well known value or null if not defined as a system value
  55056. */
  55057. systemValue: Nullable<NodeMaterialSystemValues>;
  55058. /**
  55059. * Gets the current class name
  55060. * @returns the class name
  55061. */
  55062. getClassName(): string;
  55063. /**
  55064. * Animate the input if animationType !== None
  55065. * @param scene defines the rendering scene
  55066. */
  55067. animate(scene: Scene): void;
  55068. private _emitDefine;
  55069. initialize(state: NodeMaterialBuildState): void;
  55070. /**
  55071. * Set the input block to its default value (based on its type)
  55072. */
  55073. setDefaultValue(): void;
  55074. private _emitConstant;
  55075. private _emit;
  55076. /** @hidden */
  55077. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55078. /** @hidden */
  55079. _transmit(effect: Effect, scene: Scene): void;
  55080. protected _buildBlock(state: NodeMaterialBuildState): void;
  55081. protected _dumpPropertiesCode(): string;
  55082. serialize(): any;
  55083. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55084. }
  55085. }
  55086. declare module BABYLON {
  55087. /**
  55088. * Enum used to define the compatibility state between two connection points
  55089. */
  55090. export enum NodeMaterialConnectionPointCompatibilityStates {
  55091. /** Points are compatibles */
  55092. Compatible = 0,
  55093. /** Points are incompatible because of their types */
  55094. TypeIncompatible = 1,
  55095. /** Points are incompatible because of their targets (vertex vs fragment) */
  55096. TargetIncompatible = 2
  55097. }
  55098. /**
  55099. * Defines the direction of a connection point
  55100. */
  55101. export enum NodeMaterialConnectionPointDirection {
  55102. /** Input */
  55103. Input = 0,
  55104. /** Output */
  55105. Output = 1
  55106. }
  55107. /**
  55108. * Defines a connection point for a block
  55109. */
  55110. export class NodeMaterialConnectionPoint {
  55111. /** @hidden */
  55112. _ownerBlock: NodeMaterialBlock;
  55113. /** @hidden */
  55114. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55115. private _endpoints;
  55116. private _associatedVariableName;
  55117. private _direction;
  55118. /** @hidden */
  55119. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55120. /** @hidden */
  55121. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55122. private _type;
  55123. /** @hidden */
  55124. _enforceAssociatedVariableName: boolean;
  55125. /** Gets the direction of the point */
  55126. readonly direction: NodeMaterialConnectionPointDirection;
  55127. /**
  55128. * Gets or sets the additional types supported by this connection point
  55129. */
  55130. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55131. /**
  55132. * Gets or sets the additional types excluded by this connection point
  55133. */
  55134. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55135. /**
  55136. * Observable triggered when this point is connected
  55137. */
  55138. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  55139. /**
  55140. * Gets or sets the associated variable name in the shader
  55141. */
  55142. associatedVariableName: string;
  55143. /**
  55144. * Gets or sets the connection point type (default is float)
  55145. */
  55146. type: NodeMaterialBlockConnectionPointTypes;
  55147. /**
  55148. * Gets or sets the connection point name
  55149. */
  55150. name: string;
  55151. /**
  55152. * Gets or sets a boolean indicating that this connection point can be omitted
  55153. */
  55154. isOptional: boolean;
  55155. /**
  55156. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55157. */
  55158. define: string;
  55159. /** @hidden */
  55160. _prioritizeVertex: boolean;
  55161. private _target;
  55162. /** Gets or sets the target of that connection point */
  55163. target: NodeMaterialBlockTargets;
  55164. /**
  55165. * Gets a boolean indicating that the current point is connected
  55166. */
  55167. readonly isConnected: boolean;
  55168. /**
  55169. * Gets a boolean indicating that the current point is connected to an input block
  55170. */
  55171. readonly isConnectedToInputBlock: boolean;
  55172. /**
  55173. * Gets a the connected input block (if any)
  55174. */
  55175. readonly connectInputBlock: Nullable<InputBlock>;
  55176. /** Get the other side of the connection (if any) */
  55177. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55178. /** Get the block that owns this connection point */
  55179. readonly ownerBlock: NodeMaterialBlock;
  55180. /** Get the block connected on the other side of this connection (if any) */
  55181. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55182. /** Get the block connected on the endpoints of this connection (if any) */
  55183. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55184. /** Gets the list of connected endpoints */
  55185. readonly endpoints: NodeMaterialConnectionPoint[];
  55186. /** Gets a boolean indicating if that output point is connected to at least one input */
  55187. readonly hasEndpoints: boolean;
  55188. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  55189. readonly isConnectedInVertexShader: boolean;
  55190. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  55191. readonly isConnectedInFragmentShader: boolean;
  55192. /**
  55193. * Creates a new connection point
  55194. * @param name defines the connection point name
  55195. * @param ownerBlock defines the block hosting this connection point
  55196. * @param direction defines the direction of the connection point
  55197. */
  55198. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  55199. /**
  55200. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55201. * @returns the class name
  55202. */
  55203. getClassName(): string;
  55204. /**
  55205. * Gets a boolean indicating if the current point can be connected to another point
  55206. * @param connectionPoint defines the other connection point
  55207. * @returns a boolean
  55208. */
  55209. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55210. /**
  55211. * Gets a number indicating if the current point can be connected to another point
  55212. * @param connectionPoint defines the other connection point
  55213. * @returns a number defining the compatibility state
  55214. */
  55215. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  55216. /**
  55217. * Connect this point to another connection point
  55218. * @param connectionPoint defines the other connection point
  55219. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  55220. * @returns the current connection point
  55221. */
  55222. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  55223. /**
  55224. * Disconnect this point from one of his endpoint
  55225. * @param endpoint defines the other connection point
  55226. * @returns the current connection point
  55227. */
  55228. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55229. /**
  55230. * Serializes this point in a JSON representation
  55231. * @returns the serialized point object
  55232. */
  55233. serialize(): any;
  55234. /**
  55235. * Release resources
  55236. */
  55237. dispose(): void;
  55238. }
  55239. }
  55240. declare module BABYLON {
  55241. /**
  55242. * Block used to add support for vertex skinning (bones)
  55243. */
  55244. export class BonesBlock extends NodeMaterialBlock {
  55245. /**
  55246. * Creates a new BonesBlock
  55247. * @param name defines the block name
  55248. */
  55249. constructor(name: string);
  55250. /**
  55251. * Initialize the block and prepare the context for build
  55252. * @param state defines the state that will be used for the build
  55253. */
  55254. initialize(state: NodeMaterialBuildState): void;
  55255. /**
  55256. * Gets the current class name
  55257. * @returns the class name
  55258. */
  55259. getClassName(): string;
  55260. /**
  55261. * Gets the matrix indices input component
  55262. */
  55263. readonly matricesIndices: NodeMaterialConnectionPoint;
  55264. /**
  55265. * Gets the matrix weights input component
  55266. */
  55267. readonly matricesWeights: NodeMaterialConnectionPoint;
  55268. /**
  55269. * Gets the extra matrix indices input component
  55270. */
  55271. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55272. /**
  55273. * Gets the extra matrix weights input component
  55274. */
  55275. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55276. /**
  55277. * Gets the world input component
  55278. */
  55279. readonly world: NodeMaterialConnectionPoint;
  55280. /**
  55281. * Gets the output component
  55282. */
  55283. readonly output: NodeMaterialConnectionPoint;
  55284. autoConfigure(material: NodeMaterial): void;
  55285. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55286. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55287. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55288. protected _buildBlock(state: NodeMaterialBuildState): this;
  55289. }
  55290. }
  55291. declare module BABYLON {
  55292. /**
  55293. * Block used to add support for instances
  55294. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55295. */
  55296. export class InstancesBlock extends NodeMaterialBlock {
  55297. /**
  55298. * Creates a new InstancesBlock
  55299. * @param name defines the block name
  55300. */
  55301. constructor(name: string);
  55302. /**
  55303. * Gets the current class name
  55304. * @returns the class name
  55305. */
  55306. getClassName(): string;
  55307. /**
  55308. * Gets the first world row input component
  55309. */
  55310. readonly world0: NodeMaterialConnectionPoint;
  55311. /**
  55312. * Gets the second world row input component
  55313. */
  55314. readonly world1: NodeMaterialConnectionPoint;
  55315. /**
  55316. * Gets the third world row input component
  55317. */
  55318. readonly world2: NodeMaterialConnectionPoint;
  55319. /**
  55320. * Gets the forth world row input component
  55321. */
  55322. readonly world3: NodeMaterialConnectionPoint;
  55323. /**
  55324. * Gets the world input component
  55325. */
  55326. readonly world: NodeMaterialConnectionPoint;
  55327. /**
  55328. * Gets the output component
  55329. */
  55330. readonly output: NodeMaterialConnectionPoint;
  55331. autoConfigure(material: NodeMaterial): void;
  55332. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55333. protected _buildBlock(state: NodeMaterialBuildState): this;
  55334. }
  55335. }
  55336. declare module BABYLON {
  55337. /**
  55338. * Block used to add morph targets support to vertex shader
  55339. */
  55340. export class MorphTargetsBlock extends NodeMaterialBlock {
  55341. private _repeatableContentAnchor;
  55342. private _repeatebleContentGenerated;
  55343. /**
  55344. * Create a new MorphTargetsBlock
  55345. * @param name defines the block name
  55346. */
  55347. constructor(name: string);
  55348. /**
  55349. * Gets the current class name
  55350. * @returns the class name
  55351. */
  55352. getClassName(): string;
  55353. /**
  55354. * Gets the position input component
  55355. */
  55356. readonly position: NodeMaterialConnectionPoint;
  55357. /**
  55358. * Gets the normal input component
  55359. */
  55360. readonly normal: NodeMaterialConnectionPoint;
  55361. /**
  55362. * Gets the tangent input component
  55363. */
  55364. readonly tangent: NodeMaterialConnectionPoint;
  55365. /**
  55366. * Gets the tangent input component
  55367. */
  55368. readonly uv: NodeMaterialConnectionPoint;
  55369. /**
  55370. * Gets the position output component
  55371. */
  55372. readonly positionOutput: NodeMaterialConnectionPoint;
  55373. /**
  55374. * Gets the normal output component
  55375. */
  55376. readonly normalOutput: NodeMaterialConnectionPoint;
  55377. /**
  55378. * Gets the tangent output component
  55379. */
  55380. readonly tangentOutput: NodeMaterialConnectionPoint;
  55381. /**
  55382. * Gets the tangent output component
  55383. */
  55384. readonly uvOutput: NodeMaterialConnectionPoint;
  55385. initialize(state: NodeMaterialBuildState): void;
  55386. autoConfigure(material: NodeMaterial): void;
  55387. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55388. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55389. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55390. protected _buildBlock(state: NodeMaterialBuildState): this;
  55391. }
  55392. }
  55393. declare module BABYLON {
  55394. /**
  55395. * Block used to get data information from a light
  55396. */
  55397. export class LightInformationBlock extends NodeMaterialBlock {
  55398. private _lightDataUniformName;
  55399. private _lightColorUniformName;
  55400. private _lightTypeDefineName;
  55401. /**
  55402. * Gets or sets the light associated with this block
  55403. */
  55404. light: Nullable<Light>;
  55405. /**
  55406. * Creates a new LightInformationBlock
  55407. * @param name defines the block name
  55408. */
  55409. constructor(name: string);
  55410. /**
  55411. * Gets the current class name
  55412. * @returns the class name
  55413. */
  55414. getClassName(): string;
  55415. /**
  55416. * Gets the world position input component
  55417. */
  55418. readonly worldPosition: NodeMaterialConnectionPoint;
  55419. /**
  55420. * Gets the direction output component
  55421. */
  55422. readonly direction: NodeMaterialConnectionPoint;
  55423. /**
  55424. * Gets the direction output component
  55425. */
  55426. readonly color: NodeMaterialConnectionPoint;
  55427. /**
  55428. * Gets the direction output component
  55429. */
  55430. readonly intensity: NodeMaterialConnectionPoint;
  55431. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55432. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55433. protected _buildBlock(state: NodeMaterialBuildState): this;
  55434. serialize(): any;
  55435. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55436. }
  55437. }
  55438. declare module BABYLON {
  55439. /**
  55440. * Block used to add image processing support to fragment shader
  55441. */
  55442. export class ImageProcessingBlock extends NodeMaterialBlock {
  55443. /**
  55444. * Create a new ImageProcessingBlock
  55445. * @param name defines the block name
  55446. */
  55447. constructor(name: string);
  55448. /**
  55449. * Gets the current class name
  55450. * @returns the class name
  55451. */
  55452. getClassName(): string;
  55453. /**
  55454. * Gets the color input component
  55455. */
  55456. readonly color: NodeMaterialConnectionPoint;
  55457. /**
  55458. * Gets the output component
  55459. */
  55460. readonly output: NodeMaterialConnectionPoint;
  55461. /**
  55462. * Initialize the block and prepare the context for build
  55463. * @param state defines the state that will be used for the build
  55464. */
  55465. initialize(state: NodeMaterialBuildState): void;
  55466. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  55467. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55468. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55469. protected _buildBlock(state: NodeMaterialBuildState): this;
  55470. }
  55471. }
  55472. declare module BABYLON {
  55473. /**
  55474. * Block used to pertub normals based on a normal map
  55475. */
  55476. export class PerturbNormalBlock extends NodeMaterialBlock {
  55477. private _tangentSpaceParameterName;
  55478. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  55479. invertX: boolean;
  55480. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  55481. invertY: boolean;
  55482. /**
  55483. * Create a new PerturbNormalBlock
  55484. * @param name defines the block name
  55485. */
  55486. constructor(name: string);
  55487. /**
  55488. * Gets the current class name
  55489. * @returns the class name
  55490. */
  55491. getClassName(): string;
  55492. /**
  55493. * Gets the world position input component
  55494. */
  55495. readonly worldPosition: NodeMaterialConnectionPoint;
  55496. /**
  55497. * Gets the world normal input component
  55498. */
  55499. readonly worldNormal: NodeMaterialConnectionPoint;
  55500. /**
  55501. * Gets the uv input component
  55502. */
  55503. readonly uv: NodeMaterialConnectionPoint;
  55504. /**
  55505. * Gets the normal map color input component
  55506. */
  55507. readonly normalMapColor: NodeMaterialConnectionPoint;
  55508. /**
  55509. * Gets the strength input component
  55510. */
  55511. readonly strength: NodeMaterialConnectionPoint;
  55512. /**
  55513. * Gets the output component
  55514. */
  55515. readonly output: NodeMaterialConnectionPoint;
  55516. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55517. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55518. autoConfigure(material: NodeMaterial): void;
  55519. protected _buildBlock(state: NodeMaterialBuildState): this;
  55520. protected _dumpPropertiesCode(): string;
  55521. serialize(): any;
  55522. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55523. }
  55524. }
  55525. declare module BABYLON {
  55526. /**
  55527. * Block used to discard a pixel if a value is smaller than a cutoff
  55528. */
  55529. export class DiscardBlock extends NodeMaterialBlock {
  55530. /**
  55531. * Create a new DiscardBlock
  55532. * @param name defines the block name
  55533. */
  55534. constructor(name: string);
  55535. /**
  55536. * Gets the current class name
  55537. * @returns the class name
  55538. */
  55539. getClassName(): string;
  55540. /**
  55541. * Gets the color input component
  55542. */
  55543. readonly value: NodeMaterialConnectionPoint;
  55544. /**
  55545. * Gets the cutoff input component
  55546. */
  55547. readonly cutoff: NodeMaterialConnectionPoint;
  55548. protected _buildBlock(state: NodeMaterialBuildState): this;
  55549. }
  55550. }
  55551. declare module BABYLON {
  55552. /**
  55553. * Block used to test if the fragment shader is front facing
  55554. */
  55555. export class FrontFacingBlock extends NodeMaterialBlock {
  55556. /**
  55557. * Creates a new FrontFacingBlock
  55558. * @param name defines the block name
  55559. */
  55560. constructor(name: string);
  55561. /**
  55562. * Gets the current class name
  55563. * @returns the class name
  55564. */
  55565. getClassName(): string;
  55566. /**
  55567. * Gets the output component
  55568. */
  55569. readonly output: NodeMaterialConnectionPoint;
  55570. protected _buildBlock(state: NodeMaterialBuildState): this;
  55571. }
  55572. }
  55573. declare module BABYLON {
  55574. /**
  55575. * Block used to get the derivative value on x and y of a given input
  55576. */
  55577. export class DerivativeBlock extends NodeMaterialBlock {
  55578. /**
  55579. * Create a new DerivativeBlock
  55580. * @param name defines the block name
  55581. */
  55582. constructor(name: string);
  55583. /**
  55584. * Gets the current class name
  55585. * @returns the class name
  55586. */
  55587. getClassName(): string;
  55588. /**
  55589. * Gets the input component
  55590. */
  55591. readonly input: NodeMaterialConnectionPoint;
  55592. /**
  55593. * Gets the derivative output on x
  55594. */
  55595. readonly dx: NodeMaterialConnectionPoint;
  55596. /**
  55597. * Gets the derivative output on y
  55598. */
  55599. readonly dy: NodeMaterialConnectionPoint;
  55600. protected _buildBlock(state: NodeMaterialBuildState): this;
  55601. }
  55602. }
  55603. declare module BABYLON {
  55604. /**
  55605. * Block used to add support for scene fog
  55606. */
  55607. export class FogBlock extends NodeMaterialBlock {
  55608. private _fogDistanceName;
  55609. private _fogParameters;
  55610. /**
  55611. * Create a new FogBlock
  55612. * @param name defines the block name
  55613. */
  55614. constructor(name: string);
  55615. /**
  55616. * Gets the current class name
  55617. * @returns the class name
  55618. */
  55619. getClassName(): string;
  55620. /**
  55621. * Gets the world position input component
  55622. */
  55623. readonly worldPosition: NodeMaterialConnectionPoint;
  55624. /**
  55625. * Gets the view input component
  55626. */
  55627. readonly view: NodeMaterialConnectionPoint;
  55628. /**
  55629. * Gets the color input component
  55630. */
  55631. readonly input: NodeMaterialConnectionPoint;
  55632. /**
  55633. * Gets the fog color input component
  55634. */
  55635. readonly fogColor: NodeMaterialConnectionPoint;
  55636. /**
  55637. * Gets the output component
  55638. */
  55639. readonly output: NodeMaterialConnectionPoint;
  55640. autoConfigure(material: NodeMaterial): void;
  55641. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55642. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55643. protected _buildBlock(state: NodeMaterialBuildState): this;
  55644. }
  55645. }
  55646. declare module BABYLON {
  55647. /**
  55648. * Block used to add light in the fragment shader
  55649. */
  55650. export class LightBlock extends NodeMaterialBlock {
  55651. private _lightId;
  55652. /**
  55653. * Gets or sets the light associated with this block
  55654. */
  55655. light: Nullable<Light>;
  55656. /**
  55657. * Create a new LightBlock
  55658. * @param name defines the block name
  55659. */
  55660. constructor(name: string);
  55661. /**
  55662. * Gets the current class name
  55663. * @returns the class name
  55664. */
  55665. getClassName(): string;
  55666. /**
  55667. * Gets the world position input component
  55668. */
  55669. readonly worldPosition: NodeMaterialConnectionPoint;
  55670. /**
  55671. * Gets the world normal input component
  55672. */
  55673. readonly worldNormal: NodeMaterialConnectionPoint;
  55674. /**
  55675. * Gets the camera (or eye) position component
  55676. */
  55677. readonly cameraPosition: NodeMaterialConnectionPoint;
  55678. /**
  55679. * Gets the glossiness component
  55680. */
  55681. readonly glossiness: NodeMaterialConnectionPoint;
  55682. /**
  55683. * Gets the glossinness power component
  55684. */
  55685. readonly glossPower: NodeMaterialConnectionPoint;
  55686. /**
  55687. * Gets the diffuse color component
  55688. */
  55689. readonly diffuseColor: NodeMaterialConnectionPoint;
  55690. /**
  55691. * Gets the specular color component
  55692. */
  55693. readonly specularColor: NodeMaterialConnectionPoint;
  55694. /**
  55695. * Gets the diffuse output component
  55696. */
  55697. readonly diffuseOutput: NodeMaterialConnectionPoint;
  55698. /**
  55699. * Gets the specular output component
  55700. */
  55701. readonly specularOutput: NodeMaterialConnectionPoint;
  55702. autoConfigure(material: NodeMaterial): void;
  55703. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55704. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  55705. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55706. private _injectVertexCode;
  55707. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55708. serialize(): any;
  55709. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55710. }
  55711. }
  55712. declare module BABYLON {
  55713. /**
  55714. * Block used to multiply 2 values
  55715. */
  55716. export class MultiplyBlock extends NodeMaterialBlock {
  55717. /**
  55718. * Creates a new MultiplyBlock
  55719. * @param name defines the block name
  55720. */
  55721. constructor(name: string);
  55722. /**
  55723. * Gets the current class name
  55724. * @returns the class name
  55725. */
  55726. getClassName(): string;
  55727. /**
  55728. * Gets the left operand input component
  55729. */
  55730. readonly left: NodeMaterialConnectionPoint;
  55731. /**
  55732. * Gets the right operand input component
  55733. */
  55734. readonly right: NodeMaterialConnectionPoint;
  55735. /**
  55736. * Gets the output component
  55737. */
  55738. readonly output: NodeMaterialConnectionPoint;
  55739. protected _buildBlock(state: NodeMaterialBuildState): this;
  55740. }
  55741. }
  55742. declare module BABYLON {
  55743. /**
  55744. * Block used to add 2 vectors
  55745. */
  55746. export class AddBlock extends NodeMaterialBlock {
  55747. /**
  55748. * Creates a new AddBlock
  55749. * @param name defines the block name
  55750. */
  55751. constructor(name: string);
  55752. /**
  55753. * Gets the current class name
  55754. * @returns the class name
  55755. */
  55756. getClassName(): string;
  55757. /**
  55758. * Gets the left operand input component
  55759. */
  55760. readonly left: NodeMaterialConnectionPoint;
  55761. /**
  55762. * Gets the right operand input component
  55763. */
  55764. readonly right: NodeMaterialConnectionPoint;
  55765. /**
  55766. * Gets the output component
  55767. */
  55768. readonly output: NodeMaterialConnectionPoint;
  55769. protected _buildBlock(state: NodeMaterialBuildState): this;
  55770. }
  55771. }
  55772. declare module BABYLON {
  55773. /**
  55774. * Block used to scale a vector by a float
  55775. */
  55776. export class ScaleBlock extends NodeMaterialBlock {
  55777. /**
  55778. * Creates a new ScaleBlock
  55779. * @param name defines the block name
  55780. */
  55781. constructor(name: string);
  55782. /**
  55783. * Gets the current class name
  55784. * @returns the class name
  55785. */
  55786. getClassName(): string;
  55787. /**
  55788. * Gets the input component
  55789. */
  55790. readonly input: NodeMaterialConnectionPoint;
  55791. /**
  55792. * Gets the factor input component
  55793. */
  55794. readonly factor: NodeMaterialConnectionPoint;
  55795. /**
  55796. * Gets the output component
  55797. */
  55798. readonly output: NodeMaterialConnectionPoint;
  55799. protected _buildBlock(state: NodeMaterialBuildState): this;
  55800. }
  55801. }
  55802. declare module BABYLON {
  55803. /**
  55804. * Block used to clamp a float
  55805. */
  55806. export class ClampBlock extends NodeMaterialBlock {
  55807. /** Gets or sets the minimum range */
  55808. minimum: number;
  55809. /** Gets or sets the maximum range */
  55810. maximum: number;
  55811. /**
  55812. * Creates a new ClampBlock
  55813. * @param name defines the block name
  55814. */
  55815. constructor(name: string);
  55816. /**
  55817. * Gets the current class name
  55818. * @returns the class name
  55819. */
  55820. getClassName(): string;
  55821. /**
  55822. * Gets the value input component
  55823. */
  55824. readonly value: NodeMaterialConnectionPoint;
  55825. /**
  55826. * Gets the output component
  55827. */
  55828. readonly output: NodeMaterialConnectionPoint;
  55829. protected _buildBlock(state: NodeMaterialBuildState): this;
  55830. protected _dumpPropertiesCode(): string;
  55831. serialize(): any;
  55832. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55833. }
  55834. }
  55835. declare module BABYLON {
  55836. /**
  55837. * Block used to apply a cross product between 2 vectors
  55838. */
  55839. export class CrossBlock extends NodeMaterialBlock {
  55840. /**
  55841. * Creates a new CrossBlock
  55842. * @param name defines the block name
  55843. */
  55844. constructor(name: string);
  55845. /**
  55846. * Gets the current class name
  55847. * @returns the class name
  55848. */
  55849. getClassName(): string;
  55850. /**
  55851. * Gets the left operand input component
  55852. */
  55853. readonly left: NodeMaterialConnectionPoint;
  55854. /**
  55855. * Gets the right operand input component
  55856. */
  55857. readonly right: NodeMaterialConnectionPoint;
  55858. /**
  55859. * Gets the output component
  55860. */
  55861. readonly output: NodeMaterialConnectionPoint;
  55862. protected _buildBlock(state: NodeMaterialBuildState): this;
  55863. }
  55864. }
  55865. declare module BABYLON {
  55866. /**
  55867. * Block used to apply a dot product between 2 vectors
  55868. */
  55869. export class DotBlock extends NodeMaterialBlock {
  55870. /**
  55871. * Creates a new DotBlock
  55872. * @param name defines the block name
  55873. */
  55874. constructor(name: string);
  55875. /**
  55876. * Gets the current class name
  55877. * @returns the class name
  55878. */
  55879. getClassName(): string;
  55880. /**
  55881. * Gets the left operand input component
  55882. */
  55883. readonly left: NodeMaterialConnectionPoint;
  55884. /**
  55885. * Gets the right operand input component
  55886. */
  55887. readonly right: NodeMaterialConnectionPoint;
  55888. /**
  55889. * Gets the output component
  55890. */
  55891. readonly output: NodeMaterialConnectionPoint;
  55892. protected _buildBlock(state: NodeMaterialBuildState): this;
  55893. }
  55894. }
  55895. declare module BABYLON {
  55896. /**
  55897. * Block used to remap a float from a range to a new one
  55898. */
  55899. export class RemapBlock extends NodeMaterialBlock {
  55900. /**
  55901. * Gets or sets the source range
  55902. */
  55903. sourceRange: Vector2;
  55904. /**
  55905. * Gets or sets the target range
  55906. */
  55907. targetRange: Vector2;
  55908. /**
  55909. * Creates a new RemapBlock
  55910. * @param name defines the block name
  55911. */
  55912. constructor(name: string);
  55913. /**
  55914. * Gets the current class name
  55915. * @returns the class name
  55916. */
  55917. getClassName(): string;
  55918. /**
  55919. * Gets the input component
  55920. */
  55921. readonly input: NodeMaterialConnectionPoint;
  55922. /**
  55923. * Gets the source min input component
  55924. */
  55925. readonly sourceMin: NodeMaterialConnectionPoint;
  55926. /**
  55927. * Gets the source max input component
  55928. */
  55929. readonly sourceMax: NodeMaterialConnectionPoint;
  55930. /**
  55931. * Gets the target min input component
  55932. */
  55933. readonly targetMin: NodeMaterialConnectionPoint;
  55934. /**
  55935. * Gets the target max input component
  55936. */
  55937. readonly targetMax: NodeMaterialConnectionPoint;
  55938. /**
  55939. * Gets the output component
  55940. */
  55941. readonly output: NodeMaterialConnectionPoint;
  55942. protected _buildBlock(state: NodeMaterialBuildState): this;
  55943. protected _dumpPropertiesCode(): string;
  55944. serialize(): any;
  55945. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55946. }
  55947. }
  55948. declare module BABYLON {
  55949. /**
  55950. * Block used to normalize a vector
  55951. */
  55952. export class NormalizeBlock extends NodeMaterialBlock {
  55953. /**
  55954. * Creates a new NormalizeBlock
  55955. * @param name defines the block name
  55956. */
  55957. constructor(name: string);
  55958. /**
  55959. * Gets the current class name
  55960. * @returns the class name
  55961. */
  55962. getClassName(): string;
  55963. /**
  55964. * Gets the input component
  55965. */
  55966. readonly input: NodeMaterialConnectionPoint;
  55967. /**
  55968. * Gets the output component
  55969. */
  55970. readonly output: NodeMaterialConnectionPoint;
  55971. protected _buildBlock(state: NodeMaterialBuildState): this;
  55972. }
  55973. }
  55974. declare module BABYLON {
  55975. /**
  55976. * Operations supported by the Trigonometry block
  55977. */
  55978. export enum TrigonometryBlockOperations {
  55979. /** Cos */
  55980. Cos = 0,
  55981. /** Sin */
  55982. Sin = 1,
  55983. /** Abs */
  55984. Abs = 2,
  55985. /** Exp */
  55986. Exp = 3,
  55987. /** Exp2 */
  55988. Exp2 = 4,
  55989. /** Round */
  55990. Round = 5,
  55991. /** Floor */
  55992. Floor = 6,
  55993. /** Ceiling */
  55994. Ceiling = 7,
  55995. /** Square root */
  55996. Sqrt = 8,
  55997. /** Log */
  55998. Log = 9,
  55999. /** Tangent */
  56000. Tan = 10,
  56001. /** Arc tangent */
  56002. ArcTan = 11,
  56003. /** Arc cosinus */
  56004. ArcCos = 12,
  56005. /** Arc sinus */
  56006. ArcSin = 13,
  56007. /** Fraction */
  56008. Fract = 14,
  56009. /** Sign */
  56010. Sign = 15,
  56011. /** To radians (from degrees) */
  56012. Radians = 16,
  56013. /** To degrees (from radians) */
  56014. Degrees = 17
  56015. }
  56016. /**
  56017. * Block used to apply trigonometry operation to floats
  56018. */
  56019. export class TrigonometryBlock extends NodeMaterialBlock {
  56020. /**
  56021. * Gets or sets the operation applied by the block
  56022. */
  56023. operation: TrigonometryBlockOperations;
  56024. /**
  56025. * Creates a new TrigonometryBlock
  56026. * @param name defines the block name
  56027. */
  56028. constructor(name: string);
  56029. /**
  56030. * Gets the current class name
  56031. * @returns the class name
  56032. */
  56033. getClassName(): string;
  56034. /**
  56035. * Gets the input component
  56036. */
  56037. readonly input: NodeMaterialConnectionPoint;
  56038. /**
  56039. * Gets the output component
  56040. */
  56041. readonly output: NodeMaterialConnectionPoint;
  56042. protected _buildBlock(state: NodeMaterialBuildState): this;
  56043. serialize(): any;
  56044. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56045. protected _dumpPropertiesCode(): string;
  56046. }
  56047. }
  56048. declare module BABYLON {
  56049. /**
  56050. * Block used to create a Color3/4 out of individual inputs (one for each component)
  56051. */
  56052. export class ColorMergerBlock extends NodeMaterialBlock {
  56053. /**
  56054. * Create a new ColorMergerBlock
  56055. * @param name defines the block name
  56056. */
  56057. constructor(name: string);
  56058. /**
  56059. * Gets the current class name
  56060. * @returns the class name
  56061. */
  56062. getClassName(): string;
  56063. /**
  56064. * Gets the rgb component (input)
  56065. */
  56066. readonly rgbIn: NodeMaterialConnectionPoint;
  56067. /**
  56068. * Gets the r component (input)
  56069. */
  56070. readonly r: NodeMaterialConnectionPoint;
  56071. /**
  56072. * Gets the g component (input)
  56073. */
  56074. readonly g: NodeMaterialConnectionPoint;
  56075. /**
  56076. * Gets the b component (input)
  56077. */
  56078. readonly b: NodeMaterialConnectionPoint;
  56079. /**
  56080. * Gets the a component (input)
  56081. */
  56082. readonly a: NodeMaterialConnectionPoint;
  56083. /**
  56084. * Gets the rgba component (output)
  56085. */
  56086. readonly rgba: NodeMaterialConnectionPoint;
  56087. /**
  56088. * Gets the rgb component (output)
  56089. */
  56090. readonly rgbOut: NodeMaterialConnectionPoint;
  56091. /**
  56092. * Gets the rgb component (output)
  56093. * @deprecated Please use rgbOut instead.
  56094. */
  56095. readonly rgb: NodeMaterialConnectionPoint;
  56096. protected _buildBlock(state: NodeMaterialBuildState): this;
  56097. }
  56098. }
  56099. declare module BABYLON {
  56100. /**
  56101. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  56102. */
  56103. export class VectorMergerBlock extends NodeMaterialBlock {
  56104. /**
  56105. * Create a new VectorMergerBlock
  56106. * @param name defines the block name
  56107. */
  56108. constructor(name: string);
  56109. /**
  56110. * Gets the current class name
  56111. * @returns the class name
  56112. */
  56113. getClassName(): string;
  56114. /**
  56115. * Gets the xyz component (input)
  56116. */
  56117. readonly xyzIn: NodeMaterialConnectionPoint;
  56118. /**
  56119. * Gets the xy component (input)
  56120. */
  56121. readonly xyIn: NodeMaterialConnectionPoint;
  56122. /**
  56123. * Gets the x component (input)
  56124. */
  56125. readonly x: NodeMaterialConnectionPoint;
  56126. /**
  56127. * Gets the y component (input)
  56128. */
  56129. readonly y: NodeMaterialConnectionPoint;
  56130. /**
  56131. * Gets the z component (input)
  56132. */
  56133. readonly z: NodeMaterialConnectionPoint;
  56134. /**
  56135. * Gets the w component (input)
  56136. */
  56137. readonly w: NodeMaterialConnectionPoint;
  56138. /**
  56139. * Gets the xyzw component (output)
  56140. */
  56141. readonly xyzw: NodeMaterialConnectionPoint;
  56142. /**
  56143. * Gets the xyz component (output)
  56144. */
  56145. readonly xyzOut: NodeMaterialConnectionPoint;
  56146. /**
  56147. * Gets the xy component (output)
  56148. */
  56149. readonly xyOut: NodeMaterialConnectionPoint;
  56150. /**
  56151. * Gets the xy component (output)
  56152. * @deprecated Please use xyOut instead.
  56153. */
  56154. readonly xy: NodeMaterialConnectionPoint;
  56155. /**
  56156. * Gets the xyz component (output)
  56157. * @deprecated Please use xyzOut instead.
  56158. */
  56159. readonly xyz: NodeMaterialConnectionPoint;
  56160. protected _buildBlock(state: NodeMaterialBuildState): this;
  56161. }
  56162. }
  56163. declare module BABYLON {
  56164. /**
  56165. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  56166. */
  56167. export class ColorSplitterBlock extends NodeMaterialBlock {
  56168. /**
  56169. * Create a new ColorSplitterBlock
  56170. * @param name defines the block name
  56171. */
  56172. constructor(name: string);
  56173. /**
  56174. * Gets the current class name
  56175. * @returns the class name
  56176. */
  56177. getClassName(): string;
  56178. /**
  56179. * Gets the rgba component (input)
  56180. */
  56181. readonly rgba: NodeMaterialConnectionPoint;
  56182. /**
  56183. * Gets the rgb component (input)
  56184. */
  56185. readonly rgbIn: NodeMaterialConnectionPoint;
  56186. /**
  56187. * Gets the rgb component (output)
  56188. */
  56189. readonly rgbOut: NodeMaterialConnectionPoint;
  56190. /**
  56191. * Gets the r component (output)
  56192. */
  56193. readonly r: NodeMaterialConnectionPoint;
  56194. /**
  56195. * Gets the g component (output)
  56196. */
  56197. readonly g: NodeMaterialConnectionPoint;
  56198. /**
  56199. * Gets the b component (output)
  56200. */
  56201. readonly b: NodeMaterialConnectionPoint;
  56202. /**
  56203. * Gets the a component (output)
  56204. */
  56205. readonly a: NodeMaterialConnectionPoint;
  56206. protected _inputRename(name: string): string;
  56207. protected _outputRename(name: string): string;
  56208. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56209. }
  56210. }
  56211. declare module BABYLON {
  56212. /**
  56213. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56214. */
  56215. export class VectorSplitterBlock extends NodeMaterialBlock {
  56216. /**
  56217. * Create a new VectorSplitterBlock
  56218. * @param name defines the block name
  56219. */
  56220. constructor(name: string);
  56221. /**
  56222. * Gets the current class name
  56223. * @returns the class name
  56224. */
  56225. getClassName(): string;
  56226. /**
  56227. * Gets the xyzw component (input)
  56228. */
  56229. readonly xyzw: NodeMaterialConnectionPoint;
  56230. /**
  56231. * Gets the xyz component (input)
  56232. */
  56233. readonly xyzIn: NodeMaterialConnectionPoint;
  56234. /**
  56235. * Gets the xy component (input)
  56236. */
  56237. readonly xyIn: NodeMaterialConnectionPoint;
  56238. /**
  56239. * Gets the xyz component (output)
  56240. */
  56241. readonly xyzOut: NodeMaterialConnectionPoint;
  56242. /**
  56243. * Gets the xy component (output)
  56244. */
  56245. readonly xyOut: NodeMaterialConnectionPoint;
  56246. /**
  56247. * Gets the x component (output)
  56248. */
  56249. readonly x: NodeMaterialConnectionPoint;
  56250. /**
  56251. * Gets the y component (output)
  56252. */
  56253. readonly y: NodeMaterialConnectionPoint;
  56254. /**
  56255. * Gets the z component (output)
  56256. */
  56257. readonly z: NodeMaterialConnectionPoint;
  56258. /**
  56259. * Gets the w component (output)
  56260. */
  56261. readonly w: NodeMaterialConnectionPoint;
  56262. protected _inputRename(name: string): string;
  56263. protected _outputRename(name: string): string;
  56264. protected _buildBlock(state: NodeMaterialBuildState): this;
  56265. }
  56266. }
  56267. declare module BABYLON {
  56268. /**
  56269. * Block used to lerp between 2 values
  56270. */
  56271. export class LerpBlock extends NodeMaterialBlock {
  56272. /**
  56273. * Creates a new LerpBlock
  56274. * @param name defines the block name
  56275. */
  56276. constructor(name: string);
  56277. /**
  56278. * Gets the current class name
  56279. * @returns the class name
  56280. */
  56281. getClassName(): string;
  56282. /**
  56283. * Gets the left operand input component
  56284. */
  56285. readonly left: NodeMaterialConnectionPoint;
  56286. /**
  56287. * Gets the right operand input component
  56288. */
  56289. readonly right: NodeMaterialConnectionPoint;
  56290. /**
  56291. * Gets the gradient operand input component
  56292. */
  56293. readonly gradient: NodeMaterialConnectionPoint;
  56294. /**
  56295. * Gets the output component
  56296. */
  56297. readonly output: NodeMaterialConnectionPoint;
  56298. protected _buildBlock(state: NodeMaterialBuildState): this;
  56299. }
  56300. }
  56301. declare module BABYLON {
  56302. /**
  56303. * Block used to divide 2 vectors
  56304. */
  56305. export class DivideBlock extends NodeMaterialBlock {
  56306. /**
  56307. * Creates a new DivideBlock
  56308. * @param name defines the block name
  56309. */
  56310. constructor(name: string);
  56311. /**
  56312. * Gets the current class name
  56313. * @returns the class name
  56314. */
  56315. getClassName(): string;
  56316. /**
  56317. * Gets the left operand input component
  56318. */
  56319. readonly left: NodeMaterialConnectionPoint;
  56320. /**
  56321. * Gets the right operand input component
  56322. */
  56323. readonly right: NodeMaterialConnectionPoint;
  56324. /**
  56325. * Gets the output component
  56326. */
  56327. readonly output: NodeMaterialConnectionPoint;
  56328. protected _buildBlock(state: NodeMaterialBuildState): this;
  56329. }
  56330. }
  56331. declare module BABYLON {
  56332. /**
  56333. * Block used to subtract 2 vectors
  56334. */
  56335. export class SubtractBlock extends NodeMaterialBlock {
  56336. /**
  56337. * Creates a new SubtractBlock
  56338. * @param name defines the block name
  56339. */
  56340. constructor(name: string);
  56341. /**
  56342. * Gets the current class name
  56343. * @returns the class name
  56344. */
  56345. getClassName(): string;
  56346. /**
  56347. * Gets the left operand input component
  56348. */
  56349. readonly left: NodeMaterialConnectionPoint;
  56350. /**
  56351. * Gets the right operand input component
  56352. */
  56353. readonly right: NodeMaterialConnectionPoint;
  56354. /**
  56355. * Gets the output component
  56356. */
  56357. readonly output: NodeMaterialConnectionPoint;
  56358. protected _buildBlock(state: NodeMaterialBuildState): this;
  56359. }
  56360. }
  56361. declare module BABYLON {
  56362. /**
  56363. * Block used to step a value
  56364. */
  56365. export class StepBlock extends NodeMaterialBlock {
  56366. /**
  56367. * Creates a new StepBlock
  56368. * @param name defines the block name
  56369. */
  56370. constructor(name: string);
  56371. /**
  56372. * Gets the current class name
  56373. * @returns the class name
  56374. */
  56375. getClassName(): string;
  56376. /**
  56377. * Gets the value operand input component
  56378. */
  56379. readonly value: NodeMaterialConnectionPoint;
  56380. /**
  56381. * Gets the edge operand input component
  56382. */
  56383. readonly edge: NodeMaterialConnectionPoint;
  56384. /**
  56385. * Gets the output component
  56386. */
  56387. readonly output: NodeMaterialConnectionPoint;
  56388. protected _buildBlock(state: NodeMaterialBuildState): this;
  56389. }
  56390. }
  56391. declare module BABYLON {
  56392. /**
  56393. * Block used to get the opposite (1 - x) of a value
  56394. */
  56395. export class OneMinusBlock extends NodeMaterialBlock {
  56396. /**
  56397. * Creates a new OneMinusBlock
  56398. * @param name defines the block name
  56399. */
  56400. constructor(name: string);
  56401. /**
  56402. * Gets the current class name
  56403. * @returns the class name
  56404. */
  56405. getClassName(): string;
  56406. /**
  56407. * Gets the input component
  56408. */
  56409. readonly input: NodeMaterialConnectionPoint;
  56410. /**
  56411. * Gets the output component
  56412. */
  56413. readonly output: NodeMaterialConnectionPoint;
  56414. protected _buildBlock(state: NodeMaterialBuildState): this;
  56415. }
  56416. }
  56417. declare module BABYLON {
  56418. /**
  56419. * Block used to get the view direction
  56420. */
  56421. export class ViewDirectionBlock extends NodeMaterialBlock {
  56422. /**
  56423. * Creates a new ViewDirectionBlock
  56424. * @param name defines the block name
  56425. */
  56426. constructor(name: string);
  56427. /**
  56428. * Gets the current class name
  56429. * @returns the class name
  56430. */
  56431. getClassName(): string;
  56432. /**
  56433. * Gets the world position component
  56434. */
  56435. readonly worldPosition: NodeMaterialConnectionPoint;
  56436. /**
  56437. * Gets the camera position component
  56438. */
  56439. readonly cameraPosition: NodeMaterialConnectionPoint;
  56440. /**
  56441. * Gets the output component
  56442. */
  56443. readonly output: NodeMaterialConnectionPoint;
  56444. autoConfigure(material: NodeMaterial): void;
  56445. protected _buildBlock(state: NodeMaterialBuildState): this;
  56446. }
  56447. }
  56448. declare module BABYLON {
  56449. /**
  56450. * Block used to compute fresnel value
  56451. */
  56452. export class FresnelBlock extends NodeMaterialBlock {
  56453. /**
  56454. * Create a new FresnelBlock
  56455. * @param name defines the block name
  56456. */
  56457. constructor(name: string);
  56458. /**
  56459. * Gets the current class name
  56460. * @returns the class name
  56461. */
  56462. getClassName(): string;
  56463. /**
  56464. * Gets the world normal input component
  56465. */
  56466. readonly worldNormal: NodeMaterialConnectionPoint;
  56467. /**
  56468. * Gets the view direction input component
  56469. */
  56470. readonly viewDirection: NodeMaterialConnectionPoint;
  56471. /**
  56472. * Gets the bias input component
  56473. */
  56474. readonly bias: NodeMaterialConnectionPoint;
  56475. /**
  56476. * Gets the camera (or eye) position component
  56477. */
  56478. readonly power: NodeMaterialConnectionPoint;
  56479. /**
  56480. * Gets the fresnel output component
  56481. */
  56482. readonly fresnel: NodeMaterialConnectionPoint;
  56483. autoConfigure(material: NodeMaterial): void;
  56484. protected _buildBlock(state: NodeMaterialBuildState): this;
  56485. }
  56486. }
  56487. declare module BABYLON {
  56488. /**
  56489. * Block used to get the max of 2 values
  56490. */
  56491. export class MaxBlock extends NodeMaterialBlock {
  56492. /**
  56493. * Creates a new MaxBlock
  56494. * @param name defines the block name
  56495. */
  56496. constructor(name: string);
  56497. /**
  56498. * Gets the current class name
  56499. * @returns the class name
  56500. */
  56501. getClassName(): string;
  56502. /**
  56503. * Gets the left operand input component
  56504. */
  56505. readonly left: NodeMaterialConnectionPoint;
  56506. /**
  56507. * Gets the right operand input component
  56508. */
  56509. readonly right: NodeMaterialConnectionPoint;
  56510. /**
  56511. * Gets the output component
  56512. */
  56513. readonly output: NodeMaterialConnectionPoint;
  56514. protected _buildBlock(state: NodeMaterialBuildState): this;
  56515. }
  56516. }
  56517. declare module BABYLON {
  56518. /**
  56519. * Block used to get the min of 2 values
  56520. */
  56521. export class MinBlock extends NodeMaterialBlock {
  56522. /**
  56523. * Creates a new MinBlock
  56524. * @param name defines the block name
  56525. */
  56526. constructor(name: string);
  56527. /**
  56528. * Gets the current class name
  56529. * @returns the class name
  56530. */
  56531. getClassName(): string;
  56532. /**
  56533. * Gets the left operand input component
  56534. */
  56535. readonly left: NodeMaterialConnectionPoint;
  56536. /**
  56537. * Gets the right operand input component
  56538. */
  56539. readonly right: NodeMaterialConnectionPoint;
  56540. /**
  56541. * Gets the output component
  56542. */
  56543. readonly output: NodeMaterialConnectionPoint;
  56544. protected _buildBlock(state: NodeMaterialBuildState): this;
  56545. }
  56546. }
  56547. declare module BABYLON {
  56548. /**
  56549. * Block used to get the distance between 2 values
  56550. */
  56551. export class DistanceBlock extends NodeMaterialBlock {
  56552. /**
  56553. * Creates a new DistanceBlock
  56554. * @param name defines the block name
  56555. */
  56556. constructor(name: string);
  56557. /**
  56558. * Gets the current class name
  56559. * @returns the class name
  56560. */
  56561. getClassName(): string;
  56562. /**
  56563. * Gets the left operand input component
  56564. */
  56565. readonly left: NodeMaterialConnectionPoint;
  56566. /**
  56567. * Gets the right operand input component
  56568. */
  56569. readonly right: NodeMaterialConnectionPoint;
  56570. /**
  56571. * Gets the output component
  56572. */
  56573. readonly output: NodeMaterialConnectionPoint;
  56574. protected _buildBlock(state: NodeMaterialBuildState): this;
  56575. }
  56576. }
  56577. declare module BABYLON {
  56578. /**
  56579. * Block used to get the length of a vector
  56580. */
  56581. export class LengthBlock extends NodeMaterialBlock {
  56582. /**
  56583. * Creates a new LengthBlock
  56584. * @param name defines the block name
  56585. */
  56586. constructor(name: string);
  56587. /**
  56588. * Gets the current class name
  56589. * @returns the class name
  56590. */
  56591. getClassName(): string;
  56592. /**
  56593. * Gets the value input component
  56594. */
  56595. readonly value: NodeMaterialConnectionPoint;
  56596. /**
  56597. * Gets the output component
  56598. */
  56599. readonly output: NodeMaterialConnectionPoint;
  56600. protected _buildBlock(state: NodeMaterialBuildState): this;
  56601. }
  56602. }
  56603. declare module BABYLON {
  56604. /**
  56605. * Block used to get negative version of a value (i.e. x * -1)
  56606. */
  56607. export class NegateBlock extends NodeMaterialBlock {
  56608. /**
  56609. * Creates a new NegateBlock
  56610. * @param name defines the block name
  56611. */
  56612. constructor(name: string);
  56613. /**
  56614. * Gets the current class name
  56615. * @returns the class name
  56616. */
  56617. getClassName(): string;
  56618. /**
  56619. * Gets the value input component
  56620. */
  56621. readonly value: NodeMaterialConnectionPoint;
  56622. /**
  56623. * Gets the output component
  56624. */
  56625. readonly output: NodeMaterialConnectionPoint;
  56626. protected _buildBlock(state: NodeMaterialBuildState): this;
  56627. }
  56628. }
  56629. declare module BABYLON {
  56630. /**
  56631. * Block used to get the value of the first parameter raised to the power of the second
  56632. */
  56633. export class PowBlock extends NodeMaterialBlock {
  56634. /**
  56635. * Creates a new PowBlock
  56636. * @param name defines the block name
  56637. */
  56638. constructor(name: string);
  56639. /**
  56640. * Gets the current class name
  56641. * @returns the class name
  56642. */
  56643. getClassName(): string;
  56644. /**
  56645. * Gets the value operand input component
  56646. */
  56647. readonly value: NodeMaterialConnectionPoint;
  56648. /**
  56649. * Gets the power operand input component
  56650. */
  56651. readonly power: NodeMaterialConnectionPoint;
  56652. /**
  56653. * Gets the output component
  56654. */
  56655. readonly output: NodeMaterialConnectionPoint;
  56656. protected _buildBlock(state: NodeMaterialBuildState): this;
  56657. }
  56658. }
  56659. declare module BABYLON {
  56660. /**
  56661. * Block used to get a random number
  56662. */
  56663. export class RandomNumberBlock extends NodeMaterialBlock {
  56664. /**
  56665. * Creates a new RandomNumberBlock
  56666. * @param name defines the block name
  56667. */
  56668. constructor(name: string);
  56669. /**
  56670. * Gets the current class name
  56671. * @returns the class name
  56672. */
  56673. getClassName(): string;
  56674. /**
  56675. * Gets the seed input component
  56676. */
  56677. readonly seed: NodeMaterialConnectionPoint;
  56678. /**
  56679. * Gets the output component
  56680. */
  56681. readonly output: NodeMaterialConnectionPoint;
  56682. protected _buildBlock(state: NodeMaterialBuildState): this;
  56683. }
  56684. }
  56685. declare module BABYLON {
  56686. /**
  56687. * Block used to compute arc tangent of 2 values
  56688. */
  56689. export class ArcTan2Block extends NodeMaterialBlock {
  56690. /**
  56691. * Creates a new ArcTan2Block
  56692. * @param name defines the block name
  56693. */
  56694. constructor(name: string);
  56695. /**
  56696. * Gets the current class name
  56697. * @returns the class name
  56698. */
  56699. getClassName(): string;
  56700. /**
  56701. * Gets the x operand input component
  56702. */
  56703. readonly x: NodeMaterialConnectionPoint;
  56704. /**
  56705. * Gets the y operand input component
  56706. */
  56707. readonly y: NodeMaterialConnectionPoint;
  56708. /**
  56709. * Gets the output component
  56710. */
  56711. readonly output: NodeMaterialConnectionPoint;
  56712. protected _buildBlock(state: NodeMaterialBuildState): this;
  56713. }
  56714. }
  56715. declare module BABYLON {
  56716. /**
  56717. * Block used to smooth step a value
  56718. */
  56719. export class SmoothStepBlock extends NodeMaterialBlock {
  56720. /**
  56721. * Creates a new SmoothStepBlock
  56722. * @param name defines the block name
  56723. */
  56724. constructor(name: string);
  56725. /**
  56726. * Gets the current class name
  56727. * @returns the class name
  56728. */
  56729. getClassName(): string;
  56730. /**
  56731. * Gets the value operand input component
  56732. */
  56733. readonly value: NodeMaterialConnectionPoint;
  56734. /**
  56735. * Gets the first edge operand input component
  56736. */
  56737. readonly edge0: NodeMaterialConnectionPoint;
  56738. /**
  56739. * Gets the second edge operand input component
  56740. */
  56741. readonly edge1: NodeMaterialConnectionPoint;
  56742. /**
  56743. * Gets the output component
  56744. */
  56745. readonly output: NodeMaterialConnectionPoint;
  56746. protected _buildBlock(state: NodeMaterialBuildState): this;
  56747. }
  56748. }
  56749. declare module BABYLON {
  56750. /**
  56751. * Block used to get the reciprocal (1 / x) of a value
  56752. */
  56753. export class ReciprocalBlock extends NodeMaterialBlock {
  56754. /**
  56755. * Creates a new ReciprocalBlock
  56756. * @param name defines the block name
  56757. */
  56758. constructor(name: string);
  56759. /**
  56760. * Gets the current class name
  56761. * @returns the class name
  56762. */
  56763. getClassName(): string;
  56764. /**
  56765. * Gets the input component
  56766. */
  56767. readonly input: NodeMaterialConnectionPoint;
  56768. /**
  56769. * Gets the output component
  56770. */
  56771. readonly output: NodeMaterialConnectionPoint;
  56772. protected _buildBlock(state: NodeMaterialBuildState): this;
  56773. }
  56774. }
  56775. declare module BABYLON {
  56776. /**
  56777. * Block used to replace a color by another one
  56778. */
  56779. export class ReplaceColorBlock extends NodeMaterialBlock {
  56780. /**
  56781. * Creates a new ReplaceColorBlock
  56782. * @param name defines the block name
  56783. */
  56784. constructor(name: string);
  56785. /**
  56786. * Gets the current class name
  56787. * @returns the class name
  56788. */
  56789. getClassName(): string;
  56790. /**
  56791. * Gets the value input component
  56792. */
  56793. readonly value: NodeMaterialConnectionPoint;
  56794. /**
  56795. * Gets the reference input component
  56796. */
  56797. readonly reference: NodeMaterialConnectionPoint;
  56798. /**
  56799. * Gets the distance input component
  56800. */
  56801. readonly distance: NodeMaterialConnectionPoint;
  56802. /**
  56803. * Gets the replacement input component
  56804. */
  56805. readonly replacement: NodeMaterialConnectionPoint;
  56806. /**
  56807. * Gets the output component
  56808. */
  56809. readonly output: NodeMaterialConnectionPoint;
  56810. protected _buildBlock(state: NodeMaterialBuildState): this;
  56811. }
  56812. }
  56813. declare module BABYLON {
  56814. /**
  56815. * Block used to posterize a value
  56816. * @see https://en.wikipedia.org/wiki/Posterization
  56817. */
  56818. export class PosterizeBlock extends NodeMaterialBlock {
  56819. /**
  56820. * Creates a new PosterizeBlock
  56821. * @param name defines the block name
  56822. */
  56823. constructor(name: string);
  56824. /**
  56825. * Gets the current class name
  56826. * @returns the class name
  56827. */
  56828. getClassName(): string;
  56829. /**
  56830. * Gets the value input component
  56831. */
  56832. readonly value: NodeMaterialConnectionPoint;
  56833. /**
  56834. * Gets the steps input component
  56835. */
  56836. readonly steps: NodeMaterialConnectionPoint;
  56837. /**
  56838. * Gets the output component
  56839. */
  56840. readonly output: NodeMaterialConnectionPoint;
  56841. protected _buildBlock(state: NodeMaterialBuildState): this;
  56842. }
  56843. }
  56844. declare module BABYLON {
  56845. /**
  56846. * Operations supported by the Wave block
  56847. */
  56848. export enum WaveBlockKind {
  56849. /** SawTooth */
  56850. SawTooth = 0,
  56851. /** Square */
  56852. Square = 1,
  56853. /** Triangle */
  56854. Triangle = 2
  56855. }
  56856. /**
  56857. * Block used to apply wave operation to floats
  56858. */
  56859. export class WaveBlock extends NodeMaterialBlock {
  56860. /**
  56861. * Gets or sets the kibnd of wave to be applied by the block
  56862. */
  56863. kind: WaveBlockKind;
  56864. /**
  56865. * Creates a new WaveBlock
  56866. * @param name defines the block name
  56867. */
  56868. constructor(name: string);
  56869. /**
  56870. * Gets the current class name
  56871. * @returns the class name
  56872. */
  56873. getClassName(): string;
  56874. /**
  56875. * Gets the input component
  56876. */
  56877. readonly input: NodeMaterialConnectionPoint;
  56878. /**
  56879. * Gets the output component
  56880. */
  56881. readonly output: NodeMaterialConnectionPoint;
  56882. protected _buildBlock(state: NodeMaterialBuildState): this;
  56883. serialize(): any;
  56884. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56885. }
  56886. }
  56887. declare module BABYLON {
  56888. /**
  56889. * Class used to store a color step for the GradientBlock
  56890. */
  56891. export class GradientBlockColorStep {
  56892. /**
  56893. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  56894. */
  56895. step: number;
  56896. /**
  56897. * Gets or sets the color associated with this step
  56898. */
  56899. color: Color3;
  56900. /**
  56901. * Creates a new GradientBlockColorStep
  56902. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  56903. * @param color defines the color associated with this step
  56904. */
  56905. constructor(
  56906. /**
  56907. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  56908. */
  56909. step: number,
  56910. /**
  56911. * Gets or sets the color associated with this step
  56912. */
  56913. color: Color3);
  56914. }
  56915. /**
  56916. * Block used to return a color from a gradient based on an input value between 0 and 1
  56917. */
  56918. export class GradientBlock extends NodeMaterialBlock {
  56919. /**
  56920. * Gets or sets the list of color steps
  56921. */
  56922. colorSteps: GradientBlockColorStep[];
  56923. /**
  56924. * Creates a new GradientBlock
  56925. * @param name defines the block name
  56926. */
  56927. constructor(name: string);
  56928. /**
  56929. * Gets the current class name
  56930. * @returns the class name
  56931. */
  56932. getClassName(): string;
  56933. /**
  56934. * Gets the gradient input component
  56935. */
  56936. readonly gradient: NodeMaterialConnectionPoint;
  56937. /**
  56938. * Gets the output component
  56939. */
  56940. readonly output: NodeMaterialConnectionPoint;
  56941. private _writeColorConstant;
  56942. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56943. serialize(): any;
  56944. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56945. protected _dumpPropertiesCode(): string;
  56946. }
  56947. }
  56948. declare module BABYLON {
  56949. /**
  56950. * Block used to normalize lerp between 2 values
  56951. */
  56952. export class NLerpBlock extends NodeMaterialBlock {
  56953. /**
  56954. * Creates a new NLerpBlock
  56955. * @param name defines the block name
  56956. */
  56957. constructor(name: string);
  56958. /**
  56959. * Gets the current class name
  56960. * @returns the class name
  56961. */
  56962. getClassName(): string;
  56963. /**
  56964. * Gets the left operand input component
  56965. */
  56966. readonly left: NodeMaterialConnectionPoint;
  56967. /**
  56968. * Gets the right operand input component
  56969. */
  56970. readonly right: NodeMaterialConnectionPoint;
  56971. /**
  56972. * Gets the gradient operand input component
  56973. */
  56974. readonly gradient: NodeMaterialConnectionPoint;
  56975. /**
  56976. * Gets the output component
  56977. */
  56978. readonly output: NodeMaterialConnectionPoint;
  56979. protected _buildBlock(state: NodeMaterialBuildState): this;
  56980. }
  56981. }
  56982. declare module BABYLON {
  56983. /**
  56984. * block used to Generate a Worley Noise 3D Noise Pattern
  56985. */
  56986. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  56987. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56988. manhattanDistance: boolean;
  56989. /**
  56990. * Creates a new WorleyNoise3DBlock
  56991. * @param name defines the block name
  56992. */
  56993. constructor(name: string);
  56994. /**
  56995. * Gets the current class name
  56996. * @returns the class name
  56997. */
  56998. getClassName(): string;
  56999. /**
  57000. * Gets the seed input component
  57001. */
  57002. readonly seed: NodeMaterialConnectionPoint;
  57003. /**
  57004. * Gets the jitter input component
  57005. */
  57006. readonly jitter: NodeMaterialConnectionPoint;
  57007. /**
  57008. * Gets the output component
  57009. */
  57010. readonly output: NodeMaterialConnectionPoint;
  57011. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57012. /**
  57013. * Exposes the properties to the UI?
  57014. */
  57015. protected _dumpPropertiesCode(): string;
  57016. /**
  57017. * Exposes the properties to the Seralize?
  57018. */
  57019. serialize(): any;
  57020. /**
  57021. * Exposes the properties to the deseralize?
  57022. */
  57023. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57024. }
  57025. }
  57026. declare module BABYLON {
  57027. /**
  57028. * block used to Generate a Simplex Perlin 3d Noise Pattern
  57029. */
  57030. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  57031. /**
  57032. * Creates a new SimplexPerlin3DBlock
  57033. * @param name defines the block name
  57034. */
  57035. constructor(name: string);
  57036. /**
  57037. * Gets the current class name
  57038. * @returns the class name
  57039. */
  57040. getClassName(): string;
  57041. /**
  57042. * Gets the seed operand input component
  57043. */
  57044. readonly seed: NodeMaterialConnectionPoint;
  57045. /**
  57046. * Gets the output component
  57047. */
  57048. readonly output: NodeMaterialConnectionPoint;
  57049. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57050. }
  57051. }
  57052. declare module BABYLON {
  57053. /**
  57054. * Block used to blend normals
  57055. */
  57056. export class NormalBlendBlock extends NodeMaterialBlock {
  57057. /**
  57058. * Creates a new NormalBlendBlock
  57059. * @param name defines the block name
  57060. */
  57061. constructor(name: string);
  57062. /**
  57063. * Gets the current class name
  57064. * @returns the class name
  57065. */
  57066. getClassName(): string;
  57067. /**
  57068. * Gets the first input component
  57069. */
  57070. readonly normalMap0: NodeMaterialConnectionPoint;
  57071. /**
  57072. * Gets the second input component
  57073. */
  57074. readonly normalMap1: NodeMaterialConnectionPoint;
  57075. /**
  57076. * Gets the output component
  57077. */
  57078. readonly output: NodeMaterialConnectionPoint;
  57079. protected _buildBlock(state: NodeMaterialBuildState): this;
  57080. }
  57081. }
  57082. declare module BABYLON {
  57083. /**
  57084. * Block used to rotate a 2d vector by a given angle
  57085. */
  57086. export class Rotate2dBlock extends NodeMaterialBlock {
  57087. /**
  57088. * Creates a new Rotate2dBlock
  57089. * @param name defines the block name
  57090. */
  57091. constructor(name: string);
  57092. /**
  57093. * Gets the current class name
  57094. * @returns the class name
  57095. */
  57096. getClassName(): string;
  57097. /**
  57098. * Gets the input vector
  57099. */
  57100. readonly input: NodeMaterialConnectionPoint;
  57101. /**
  57102. * Gets the input angle
  57103. */
  57104. readonly angle: NodeMaterialConnectionPoint;
  57105. /**
  57106. * Gets the output component
  57107. */
  57108. readonly output: NodeMaterialConnectionPoint;
  57109. autoConfigure(material: NodeMaterial): void;
  57110. protected _buildBlock(state: NodeMaterialBuildState): this;
  57111. }
  57112. }
  57113. declare module BABYLON {
  57114. /**
  57115. * Block used to get the reflected vector from a direction and a normal
  57116. */
  57117. export class ReflectBlock extends NodeMaterialBlock {
  57118. /**
  57119. * Creates a new ReflectBlock
  57120. * @param name defines the block name
  57121. */
  57122. constructor(name: string);
  57123. /**
  57124. * Gets the current class name
  57125. * @returns the class name
  57126. */
  57127. getClassName(): string;
  57128. /**
  57129. * Gets the incident component
  57130. */
  57131. readonly incident: NodeMaterialConnectionPoint;
  57132. /**
  57133. * Gets the normal component
  57134. */
  57135. readonly normal: NodeMaterialConnectionPoint;
  57136. /**
  57137. * Gets the output component
  57138. */
  57139. readonly output: NodeMaterialConnectionPoint;
  57140. protected _buildBlock(state: NodeMaterialBuildState): this;
  57141. }
  57142. }
  57143. declare module BABYLON {
  57144. /**
  57145. * Block used to get the refracted vector from a direction and a normal
  57146. */
  57147. export class RefractBlock extends NodeMaterialBlock {
  57148. /**
  57149. * Creates a new RefractBlock
  57150. * @param name defines the block name
  57151. */
  57152. constructor(name: string);
  57153. /**
  57154. * Gets the current class name
  57155. * @returns the class name
  57156. */
  57157. getClassName(): string;
  57158. /**
  57159. * Gets the incident component
  57160. */
  57161. readonly incident: NodeMaterialConnectionPoint;
  57162. /**
  57163. * Gets the normal component
  57164. */
  57165. readonly normal: NodeMaterialConnectionPoint;
  57166. /**
  57167. * Gets the index of refraction component
  57168. */
  57169. readonly ior: NodeMaterialConnectionPoint;
  57170. /**
  57171. * Gets the output component
  57172. */
  57173. readonly output: NodeMaterialConnectionPoint;
  57174. protected _buildBlock(state: NodeMaterialBuildState): this;
  57175. }
  57176. }
  57177. declare module BABYLON {
  57178. /**
  57179. * Block used to desaturate a color
  57180. */
  57181. export class DesaturateBlock extends NodeMaterialBlock {
  57182. /**
  57183. * Creates a new DesaturateBlock
  57184. * @param name defines the block name
  57185. */
  57186. constructor(name: string);
  57187. /**
  57188. * Gets the current class name
  57189. * @returns the class name
  57190. */
  57191. getClassName(): string;
  57192. /**
  57193. * Gets the color operand input component
  57194. */
  57195. readonly color: NodeMaterialConnectionPoint;
  57196. /**
  57197. * Gets the level operand input component
  57198. */
  57199. readonly level: NodeMaterialConnectionPoint;
  57200. /**
  57201. * Gets the output component
  57202. */
  57203. readonly output: NodeMaterialConnectionPoint;
  57204. protected _buildBlock(state: NodeMaterialBuildState): this;
  57205. }
  57206. }
  57207. declare module BABYLON {
  57208. /**
  57209. * Effect Render Options
  57210. */
  57211. export interface IEffectRendererOptions {
  57212. /**
  57213. * Defines the vertices positions.
  57214. */
  57215. positions?: number[];
  57216. /**
  57217. * Defines the indices.
  57218. */
  57219. indices?: number[];
  57220. }
  57221. /**
  57222. * Helper class to render one or more effects
  57223. */
  57224. export class EffectRenderer {
  57225. private engine;
  57226. private static _DefaultOptions;
  57227. private _vertexBuffers;
  57228. private _indexBuffer;
  57229. private _ringBufferIndex;
  57230. private _ringScreenBuffer;
  57231. private _fullscreenViewport;
  57232. private _getNextFrameBuffer;
  57233. /**
  57234. * Creates an effect renderer
  57235. * @param engine the engine to use for rendering
  57236. * @param options defines the options of the effect renderer
  57237. */
  57238. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  57239. /**
  57240. * Sets the current viewport in normalized coordinates 0-1
  57241. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  57242. */
  57243. setViewport(viewport?: Viewport): void;
  57244. /**
  57245. * Binds the embedded attributes buffer to the effect.
  57246. * @param effect Defines the effect to bind the attributes for
  57247. */
  57248. bindBuffers(effect: Effect): void;
  57249. /**
  57250. * Sets the current effect wrapper to use during draw.
  57251. * The effect needs to be ready before calling this api.
  57252. * This also sets the default full screen position attribute.
  57253. * @param effectWrapper Defines the effect to draw with
  57254. */
  57255. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  57256. /**
  57257. * Draws a full screen quad.
  57258. */
  57259. draw(): void;
  57260. /**
  57261. * renders one or more effects to a specified texture
  57262. * @param effectWrappers list of effects to renderer
  57263. * @param outputTexture texture to draw to, if null it will render to the screen
  57264. */
  57265. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  57266. /**
  57267. * Disposes of the effect renderer
  57268. */
  57269. dispose(): void;
  57270. }
  57271. /**
  57272. * Options to create an EffectWrapper
  57273. */
  57274. interface EffectWrapperCreationOptions {
  57275. /**
  57276. * Engine to use to create the effect
  57277. */
  57278. engine: ThinEngine;
  57279. /**
  57280. * Fragment shader for the effect
  57281. */
  57282. fragmentShader: string;
  57283. /**
  57284. * Vertex shader for the effect
  57285. */
  57286. vertexShader?: string;
  57287. /**
  57288. * Attributes to use in the shader
  57289. */
  57290. attributeNames?: Array<string>;
  57291. /**
  57292. * Uniforms to use in the shader
  57293. */
  57294. uniformNames?: Array<string>;
  57295. /**
  57296. * Texture sampler names to use in the shader
  57297. */
  57298. samplerNames?: Array<string>;
  57299. /**
  57300. * The friendly name of the effect displayed in Spector.
  57301. */
  57302. name?: string;
  57303. }
  57304. /**
  57305. * Wraps an effect to be used for rendering
  57306. */
  57307. export class EffectWrapper {
  57308. /**
  57309. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  57310. */
  57311. onApplyObservable: Observable<{}>;
  57312. /**
  57313. * The underlying effect
  57314. */
  57315. effect: Effect;
  57316. /**
  57317. * Creates an effect to be renderer
  57318. * @param creationOptions options to create the effect
  57319. */
  57320. constructor(creationOptions: EffectWrapperCreationOptions);
  57321. /**
  57322. * Disposes of the effect wrapper
  57323. */
  57324. dispose(): void;
  57325. }
  57326. }
  57327. declare module BABYLON {
  57328. /**
  57329. * Helper class to push actions to a pool of workers.
  57330. */
  57331. export class WorkerPool implements IDisposable {
  57332. private _workerInfos;
  57333. private _pendingActions;
  57334. /**
  57335. * Constructor
  57336. * @param workers Array of workers to use for actions
  57337. */
  57338. constructor(workers: Array<Worker>);
  57339. /**
  57340. * Terminates all workers and clears any pending actions.
  57341. */
  57342. dispose(): void;
  57343. /**
  57344. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57345. * pended until a worker has completed its action.
  57346. * @param action The action to perform. Call onComplete when the action is complete.
  57347. */
  57348. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57349. private _execute;
  57350. }
  57351. }
  57352. declare module BABYLON {
  57353. /**
  57354. * Configuration for Draco compression
  57355. */
  57356. export interface IDracoCompressionConfiguration {
  57357. /**
  57358. * Configuration for the decoder.
  57359. */
  57360. decoder: {
  57361. /**
  57362. * The url to the WebAssembly module.
  57363. */
  57364. wasmUrl?: string;
  57365. /**
  57366. * The url to the WebAssembly binary.
  57367. */
  57368. wasmBinaryUrl?: string;
  57369. /**
  57370. * The url to the fallback JavaScript module.
  57371. */
  57372. fallbackUrl?: string;
  57373. };
  57374. }
  57375. /**
  57376. * Draco compression (https://google.github.io/draco/)
  57377. *
  57378. * This class wraps the Draco module.
  57379. *
  57380. * **Encoder**
  57381. *
  57382. * The encoder is not currently implemented.
  57383. *
  57384. * **Decoder**
  57385. *
  57386. * 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.
  57387. *
  57388. * To update the configuration, use the following code:
  57389. * ```javascript
  57390. * DracoCompression.Configuration = {
  57391. * decoder: {
  57392. * wasmUrl: "<url to the WebAssembly library>",
  57393. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  57394. * fallbackUrl: "<url to the fallback JavaScript library>",
  57395. * }
  57396. * };
  57397. * ```
  57398. *
  57399. * 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.
  57400. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  57401. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  57402. *
  57403. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  57404. * ```javascript
  57405. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  57406. * ```
  57407. *
  57408. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  57409. */
  57410. export class DracoCompression implements IDisposable {
  57411. private _workerPoolPromise?;
  57412. private _decoderModulePromise?;
  57413. /**
  57414. * The configuration. Defaults to the following urls:
  57415. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  57416. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  57417. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  57418. */
  57419. static Configuration: IDracoCompressionConfiguration;
  57420. /**
  57421. * Returns true if the decoder configuration is available.
  57422. */
  57423. static readonly DecoderAvailable: boolean;
  57424. /**
  57425. * Default number of workers to create when creating the draco compression object.
  57426. */
  57427. static DefaultNumWorkers: number;
  57428. private static GetDefaultNumWorkers;
  57429. private static _Default;
  57430. /**
  57431. * Default instance for the draco compression object.
  57432. */
  57433. static readonly Default: DracoCompression;
  57434. /**
  57435. * Constructor
  57436. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57437. */
  57438. constructor(numWorkers?: number);
  57439. /**
  57440. * Stop all async operations and release resources.
  57441. */
  57442. dispose(): void;
  57443. /**
  57444. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  57445. * @returns a promise that resolves when ready
  57446. */
  57447. whenReadyAsync(): Promise<void>;
  57448. /**
  57449. * Decode Draco compressed mesh data to vertex data.
  57450. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  57451. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  57452. * @returns A promise that resolves with the decoded vertex data
  57453. */
  57454. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  57455. [kind: string]: number;
  57456. }): Promise<VertexData>;
  57457. }
  57458. }
  57459. declare module BABYLON {
  57460. /**
  57461. * Class for building Constructive Solid Geometry
  57462. */
  57463. export class CSG {
  57464. private polygons;
  57465. /**
  57466. * The world matrix
  57467. */
  57468. matrix: Matrix;
  57469. /**
  57470. * Stores the position
  57471. */
  57472. position: Vector3;
  57473. /**
  57474. * Stores the rotation
  57475. */
  57476. rotation: Vector3;
  57477. /**
  57478. * Stores the rotation quaternion
  57479. */
  57480. rotationQuaternion: Nullable<Quaternion>;
  57481. /**
  57482. * Stores the scaling vector
  57483. */
  57484. scaling: Vector3;
  57485. /**
  57486. * Convert the Mesh to CSG
  57487. * @param mesh The Mesh to convert to CSG
  57488. * @returns A new CSG from the Mesh
  57489. */
  57490. static FromMesh(mesh: Mesh): CSG;
  57491. /**
  57492. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  57493. * @param polygons Polygons used to construct a CSG solid
  57494. */
  57495. private static FromPolygons;
  57496. /**
  57497. * Clones, or makes a deep copy, of the CSG
  57498. * @returns A new CSG
  57499. */
  57500. clone(): CSG;
  57501. /**
  57502. * Unions this CSG with another CSG
  57503. * @param csg The CSG to union against this CSG
  57504. * @returns The unioned CSG
  57505. */
  57506. union(csg: CSG): CSG;
  57507. /**
  57508. * Unions this CSG with another CSG in place
  57509. * @param csg The CSG to union against this CSG
  57510. */
  57511. unionInPlace(csg: CSG): void;
  57512. /**
  57513. * Subtracts this CSG with another CSG
  57514. * @param csg The CSG to subtract against this CSG
  57515. * @returns A new CSG
  57516. */
  57517. subtract(csg: CSG): CSG;
  57518. /**
  57519. * Subtracts this CSG with another CSG in place
  57520. * @param csg The CSG to subtact against this CSG
  57521. */
  57522. subtractInPlace(csg: CSG): void;
  57523. /**
  57524. * Intersect this CSG with another CSG
  57525. * @param csg The CSG to intersect against this CSG
  57526. * @returns A new CSG
  57527. */
  57528. intersect(csg: CSG): CSG;
  57529. /**
  57530. * Intersects this CSG with another CSG in place
  57531. * @param csg The CSG to intersect against this CSG
  57532. */
  57533. intersectInPlace(csg: CSG): void;
  57534. /**
  57535. * Return a new CSG solid with solid and empty space switched. This solid is
  57536. * not modified.
  57537. * @returns A new CSG solid with solid and empty space switched
  57538. */
  57539. inverse(): CSG;
  57540. /**
  57541. * Inverses the CSG in place
  57542. */
  57543. inverseInPlace(): void;
  57544. /**
  57545. * This is used to keep meshes transformations so they can be restored
  57546. * when we build back a Babylon Mesh
  57547. * NB : All CSG operations are performed in world coordinates
  57548. * @param csg The CSG to copy the transform attributes from
  57549. * @returns This CSG
  57550. */
  57551. copyTransformAttributes(csg: CSG): CSG;
  57552. /**
  57553. * Build Raw mesh from CSG
  57554. * Coordinates here are in world space
  57555. * @param name The name of the mesh geometry
  57556. * @param scene The Scene
  57557. * @param keepSubMeshes Specifies if the submeshes should be kept
  57558. * @returns A new Mesh
  57559. */
  57560. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57561. /**
  57562. * Build Mesh from CSG taking material and transforms into account
  57563. * @param name The name of the Mesh
  57564. * @param material The material of the Mesh
  57565. * @param scene The Scene
  57566. * @param keepSubMeshes Specifies if submeshes should be kept
  57567. * @returns The new Mesh
  57568. */
  57569. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57570. }
  57571. }
  57572. declare module BABYLON {
  57573. /**
  57574. * Class used to create a trail following a mesh
  57575. */
  57576. export class TrailMesh extends Mesh {
  57577. private _generator;
  57578. private _autoStart;
  57579. private _running;
  57580. private _diameter;
  57581. private _length;
  57582. private _sectionPolygonPointsCount;
  57583. private _sectionVectors;
  57584. private _sectionNormalVectors;
  57585. private _beforeRenderObserver;
  57586. /**
  57587. * @constructor
  57588. * @param name The value used by scene.getMeshByName() to do a lookup.
  57589. * @param generator The mesh to generate a trail.
  57590. * @param scene The scene to add this mesh to.
  57591. * @param diameter Diameter of trailing mesh. Default is 1.
  57592. * @param length Length of trailing mesh. Default is 60.
  57593. * @param autoStart Automatically start trailing mesh. Default true.
  57594. */
  57595. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  57596. /**
  57597. * "TrailMesh"
  57598. * @returns "TrailMesh"
  57599. */
  57600. getClassName(): string;
  57601. private _createMesh;
  57602. /**
  57603. * Start trailing mesh.
  57604. */
  57605. start(): void;
  57606. /**
  57607. * Stop trailing mesh.
  57608. */
  57609. stop(): void;
  57610. /**
  57611. * Update trailing mesh geometry.
  57612. */
  57613. update(): void;
  57614. /**
  57615. * Returns a new TrailMesh object.
  57616. * @param name is a string, the name given to the new mesh
  57617. * @param newGenerator use new generator object for cloned trail mesh
  57618. * @returns a new mesh
  57619. */
  57620. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  57621. /**
  57622. * Serializes this trail mesh
  57623. * @param serializationObject object to write serialization to
  57624. */
  57625. serialize(serializationObject: any): void;
  57626. /**
  57627. * Parses a serialized trail mesh
  57628. * @param parsedMesh the serialized mesh
  57629. * @param scene the scene to create the trail mesh in
  57630. * @returns the created trail mesh
  57631. */
  57632. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  57633. }
  57634. }
  57635. declare module BABYLON {
  57636. /**
  57637. * Class containing static functions to help procedurally build meshes
  57638. */
  57639. export class TiledBoxBuilder {
  57640. /**
  57641. * Creates a box mesh
  57642. * 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)
  57643. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57645. * * 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
  57646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57647. * @param name defines the name of the mesh
  57648. * @param options defines the options used to create the mesh
  57649. * @param scene defines the hosting scene
  57650. * @returns the box mesh
  57651. */
  57652. static CreateTiledBox(name: string, options: {
  57653. pattern?: number;
  57654. width?: number;
  57655. height?: number;
  57656. depth?: number;
  57657. tileSize?: number;
  57658. tileWidth?: number;
  57659. tileHeight?: number;
  57660. alignHorizontal?: number;
  57661. alignVertical?: number;
  57662. faceUV?: Vector4[];
  57663. faceColors?: Color4[];
  57664. sideOrientation?: number;
  57665. updatable?: boolean;
  57666. }, scene?: Nullable<Scene>): Mesh;
  57667. }
  57668. }
  57669. declare module BABYLON {
  57670. /**
  57671. * Class containing static functions to help procedurally build meshes
  57672. */
  57673. export class TorusKnotBuilder {
  57674. /**
  57675. * Creates a torus knot mesh
  57676. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57677. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57678. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57679. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57681. * * 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
  57682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57683. * @param name defines the name of the mesh
  57684. * @param options defines the options used to create the mesh
  57685. * @param scene defines the hosting scene
  57686. * @returns the torus knot mesh
  57687. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57688. */
  57689. static CreateTorusKnot(name: string, options: {
  57690. radius?: number;
  57691. tube?: number;
  57692. radialSegments?: number;
  57693. tubularSegments?: number;
  57694. p?: number;
  57695. q?: number;
  57696. updatable?: boolean;
  57697. sideOrientation?: number;
  57698. frontUVs?: Vector4;
  57699. backUVs?: Vector4;
  57700. }, scene: any): Mesh;
  57701. }
  57702. }
  57703. declare module BABYLON {
  57704. /**
  57705. * Polygon
  57706. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  57707. */
  57708. export class Polygon {
  57709. /**
  57710. * Creates a rectangle
  57711. * @param xmin bottom X coord
  57712. * @param ymin bottom Y coord
  57713. * @param xmax top X coord
  57714. * @param ymax top Y coord
  57715. * @returns points that make the resulting rectation
  57716. */
  57717. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  57718. /**
  57719. * Creates a circle
  57720. * @param radius radius of circle
  57721. * @param cx scale in x
  57722. * @param cy scale in y
  57723. * @param numberOfSides number of sides that make up the circle
  57724. * @returns points that make the resulting circle
  57725. */
  57726. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  57727. /**
  57728. * Creates a polygon from input string
  57729. * @param input Input polygon data
  57730. * @returns the parsed points
  57731. */
  57732. static Parse(input: string): Vector2[];
  57733. /**
  57734. * Starts building a polygon from x and y coordinates
  57735. * @param x x coordinate
  57736. * @param y y coordinate
  57737. * @returns the started path2
  57738. */
  57739. static StartingAt(x: number, y: number): Path2;
  57740. }
  57741. /**
  57742. * Builds a polygon
  57743. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  57744. */
  57745. export class PolygonMeshBuilder {
  57746. private _points;
  57747. private _outlinepoints;
  57748. private _holes;
  57749. private _name;
  57750. private _scene;
  57751. private _epoints;
  57752. private _eholes;
  57753. private _addToepoint;
  57754. /**
  57755. * Babylon reference to the earcut plugin.
  57756. */
  57757. bjsEarcut: any;
  57758. /**
  57759. * Creates a PolygonMeshBuilder
  57760. * @param name name of the builder
  57761. * @param contours Path of the polygon
  57762. * @param scene scene to add to when creating the mesh
  57763. * @param earcutInjection can be used to inject your own earcut reference
  57764. */
  57765. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  57766. /**
  57767. * Adds a whole within the polygon
  57768. * @param hole Array of points defining the hole
  57769. * @returns this
  57770. */
  57771. addHole(hole: Vector2[]): PolygonMeshBuilder;
  57772. /**
  57773. * Creates the polygon
  57774. * @param updatable If the mesh should be updatable
  57775. * @param depth The depth of the mesh created
  57776. * @returns the created mesh
  57777. */
  57778. build(updatable?: boolean, depth?: number): Mesh;
  57779. /**
  57780. * Creates the polygon
  57781. * @param depth The depth of the mesh created
  57782. * @returns the created VertexData
  57783. */
  57784. buildVertexData(depth?: number): VertexData;
  57785. /**
  57786. * Adds a side to the polygon
  57787. * @param positions points that make the polygon
  57788. * @param normals normals of the polygon
  57789. * @param uvs uvs of the polygon
  57790. * @param indices indices of the polygon
  57791. * @param bounds bounds of the polygon
  57792. * @param points points of the polygon
  57793. * @param depth depth of the polygon
  57794. * @param flip flip of the polygon
  57795. */
  57796. private addSide;
  57797. }
  57798. }
  57799. declare module BABYLON {
  57800. /**
  57801. * Class containing static functions to help procedurally build meshes
  57802. */
  57803. export class PolygonBuilder {
  57804. /**
  57805. * Creates a polygon mesh
  57806. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57807. * * 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
  57808. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57810. * * 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)
  57811. * * Remember you can only change the shape positions, not their number when updating a polygon
  57812. * @param name defines the name of the mesh
  57813. * @param options defines the options used to create the mesh
  57814. * @param scene defines the hosting scene
  57815. * @param earcutInjection can be used to inject your own earcut reference
  57816. * @returns the polygon mesh
  57817. */
  57818. static CreatePolygon(name: string, options: {
  57819. shape: Vector3[];
  57820. holes?: Vector3[][];
  57821. depth?: number;
  57822. faceUV?: Vector4[];
  57823. faceColors?: Color4[];
  57824. updatable?: boolean;
  57825. sideOrientation?: number;
  57826. frontUVs?: Vector4;
  57827. backUVs?: Vector4;
  57828. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57829. /**
  57830. * Creates an extruded polygon mesh, with depth in the Y direction.
  57831. * * 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)
  57832. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57833. * @param name defines the name of the mesh
  57834. * @param options defines the options used to create the mesh
  57835. * @param scene defines the hosting scene
  57836. * @param earcutInjection can be used to inject your own earcut reference
  57837. * @returns the polygon mesh
  57838. */
  57839. static ExtrudePolygon(name: string, options: {
  57840. shape: Vector3[];
  57841. holes?: Vector3[][];
  57842. depth?: number;
  57843. faceUV?: Vector4[];
  57844. faceColors?: Color4[];
  57845. updatable?: boolean;
  57846. sideOrientation?: number;
  57847. frontUVs?: Vector4;
  57848. backUVs?: Vector4;
  57849. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57850. }
  57851. }
  57852. declare module BABYLON {
  57853. /**
  57854. * Class containing static functions to help procedurally build meshes
  57855. */
  57856. export class LatheBuilder {
  57857. /**
  57858. * Creates lathe mesh.
  57859. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57860. * * 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
  57861. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57862. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57863. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57864. * * 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
  57865. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57866. * * 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
  57867. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57868. * * 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
  57869. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57871. * @param name defines the name of the mesh
  57872. * @param options defines the options used to create the mesh
  57873. * @param scene defines the hosting scene
  57874. * @returns the lathe mesh
  57875. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57876. */
  57877. static CreateLathe(name: string, options: {
  57878. shape: Vector3[];
  57879. radius?: number;
  57880. tessellation?: number;
  57881. clip?: number;
  57882. arc?: number;
  57883. closed?: boolean;
  57884. updatable?: boolean;
  57885. sideOrientation?: number;
  57886. frontUVs?: Vector4;
  57887. backUVs?: Vector4;
  57888. cap?: number;
  57889. invertUV?: boolean;
  57890. }, scene?: Nullable<Scene>): Mesh;
  57891. }
  57892. }
  57893. declare module BABYLON {
  57894. /**
  57895. * Class containing static functions to help procedurally build meshes
  57896. */
  57897. export class TiledPlaneBuilder {
  57898. /**
  57899. * Creates a tiled plane mesh
  57900. * * The parameter `pattern` will, depending on value, do nothing or
  57901. * * * flip (reflect about central vertical) alternate tiles across and up
  57902. * * * flip every tile on alternate rows
  57903. * * * rotate (180 degs) alternate tiles across and up
  57904. * * * rotate every tile on alternate rows
  57905. * * * flip and rotate alternate tiles across and up
  57906. * * * flip and rotate every tile on alternate rows
  57907. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  57908. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  57909. * * 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
  57910. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57911. * * 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)
  57912. * * 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)
  57913. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57914. * @param name defines the name of the mesh
  57915. * @param options defines the options used to create the mesh
  57916. * @param scene defines the hosting scene
  57917. * @returns the box mesh
  57918. */
  57919. static CreateTiledPlane(name: string, options: {
  57920. pattern?: number;
  57921. tileSize?: number;
  57922. tileWidth?: number;
  57923. tileHeight?: number;
  57924. size?: number;
  57925. width?: number;
  57926. height?: number;
  57927. alignHorizontal?: number;
  57928. alignVertical?: number;
  57929. sideOrientation?: number;
  57930. frontUVs?: Vector4;
  57931. backUVs?: Vector4;
  57932. updatable?: boolean;
  57933. }, scene?: Nullable<Scene>): Mesh;
  57934. }
  57935. }
  57936. declare module BABYLON {
  57937. /**
  57938. * Class containing static functions to help procedurally build meshes
  57939. */
  57940. export class TubeBuilder {
  57941. /**
  57942. * Creates a tube mesh.
  57943. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57944. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57945. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57946. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57947. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57948. * * 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)
  57949. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57950. * * 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
  57951. * * 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
  57952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57953. * * 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
  57954. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57956. * @param name defines the name of the mesh
  57957. * @param options defines the options used to create the mesh
  57958. * @param scene defines the hosting scene
  57959. * @returns the tube mesh
  57960. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57961. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57962. */
  57963. static CreateTube(name: string, options: {
  57964. path: Vector3[];
  57965. radius?: number;
  57966. tessellation?: number;
  57967. radiusFunction?: {
  57968. (i: number, distance: number): number;
  57969. };
  57970. cap?: number;
  57971. arc?: number;
  57972. updatable?: boolean;
  57973. sideOrientation?: number;
  57974. frontUVs?: Vector4;
  57975. backUVs?: Vector4;
  57976. instance?: Mesh;
  57977. invertUV?: boolean;
  57978. }, scene?: Nullable<Scene>): Mesh;
  57979. }
  57980. }
  57981. declare module BABYLON {
  57982. /**
  57983. * Class containing static functions to help procedurally build meshes
  57984. */
  57985. export class IcoSphereBuilder {
  57986. /**
  57987. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57988. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57989. * * 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`)
  57990. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57991. * * 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
  57992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57993. * * 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
  57994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57995. * @param name defines the name of the mesh
  57996. * @param options defines the options used to create the mesh
  57997. * @param scene defines the hosting scene
  57998. * @returns the icosahedron mesh
  57999. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58000. */
  58001. static CreateIcoSphere(name: string, options: {
  58002. radius?: number;
  58003. radiusX?: number;
  58004. radiusY?: number;
  58005. radiusZ?: number;
  58006. flat?: boolean;
  58007. subdivisions?: number;
  58008. sideOrientation?: number;
  58009. frontUVs?: Vector4;
  58010. backUVs?: Vector4;
  58011. updatable?: boolean;
  58012. }, scene?: Nullable<Scene>): Mesh;
  58013. }
  58014. }
  58015. declare module BABYLON {
  58016. /**
  58017. * Class containing static functions to help procedurally build meshes
  58018. */
  58019. export class DecalBuilder {
  58020. /**
  58021. * Creates a decal mesh.
  58022. * 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
  58023. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58024. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58025. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58026. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58027. * @param name defines the name of the mesh
  58028. * @param sourceMesh defines the mesh where the decal must be applied
  58029. * @param options defines the options used to create the mesh
  58030. * @param scene defines the hosting scene
  58031. * @returns the decal mesh
  58032. * @see https://doc.babylonjs.com/how_to/decals
  58033. */
  58034. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58035. position?: Vector3;
  58036. normal?: Vector3;
  58037. size?: Vector3;
  58038. angle?: number;
  58039. }): Mesh;
  58040. }
  58041. }
  58042. declare module BABYLON {
  58043. /**
  58044. * Class containing static functions to help procedurally build meshes
  58045. */
  58046. export class MeshBuilder {
  58047. /**
  58048. * Creates a box mesh
  58049. * * The parameter `size` sets the size (float) of each box side (default 1)
  58050. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  58051. * * 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)
  58052. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58054. * * 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
  58055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58056. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58057. * @param name defines the name of the mesh
  58058. * @param options defines the options used to create the mesh
  58059. * @param scene defines the hosting scene
  58060. * @returns the box mesh
  58061. */
  58062. static CreateBox(name: string, options: {
  58063. size?: number;
  58064. width?: number;
  58065. height?: number;
  58066. depth?: number;
  58067. faceUV?: Vector4[];
  58068. faceColors?: Color4[];
  58069. sideOrientation?: number;
  58070. frontUVs?: Vector4;
  58071. backUVs?: Vector4;
  58072. updatable?: boolean;
  58073. }, scene?: Nullable<Scene>): Mesh;
  58074. /**
  58075. * Creates a tiled box mesh
  58076. * * faceTiles sets the pattern, tile size and number of tiles for a face
  58077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58078. * @param name defines the name of the mesh
  58079. * @param options defines the options used to create the mesh
  58080. * @param scene defines the hosting scene
  58081. * @returns the tiled box mesh
  58082. */
  58083. static CreateTiledBox(name: string, options: {
  58084. pattern?: number;
  58085. size?: number;
  58086. width?: number;
  58087. height?: number;
  58088. depth: number;
  58089. tileSize?: number;
  58090. tileWidth?: number;
  58091. tileHeight?: number;
  58092. faceUV?: Vector4[];
  58093. faceColors?: Color4[];
  58094. alignHorizontal?: number;
  58095. alignVertical?: number;
  58096. sideOrientation?: number;
  58097. updatable?: boolean;
  58098. }, scene?: Nullable<Scene>): Mesh;
  58099. /**
  58100. * Creates a sphere mesh
  58101. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  58102. * * 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`)
  58103. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  58104. * * 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
  58105. * * 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)
  58106. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58107. * * 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
  58108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58109. * @param name defines the name of the mesh
  58110. * @param options defines the options used to create the mesh
  58111. * @param scene defines the hosting scene
  58112. * @returns the sphere mesh
  58113. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  58114. */
  58115. static CreateSphere(name: string, options: {
  58116. segments?: number;
  58117. diameter?: number;
  58118. diameterX?: number;
  58119. diameterY?: number;
  58120. diameterZ?: number;
  58121. arc?: number;
  58122. slice?: number;
  58123. sideOrientation?: number;
  58124. frontUVs?: Vector4;
  58125. backUVs?: Vector4;
  58126. updatable?: boolean;
  58127. }, scene?: Nullable<Scene>): Mesh;
  58128. /**
  58129. * Creates a plane polygonal mesh. By default, this is a disc
  58130. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  58131. * * 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
  58132. * * 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
  58133. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58134. * * 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
  58135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58136. * @param name defines the name of the mesh
  58137. * @param options defines the options used to create the mesh
  58138. * @param scene defines the hosting scene
  58139. * @returns the plane polygonal mesh
  58140. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  58141. */
  58142. static CreateDisc(name: string, options: {
  58143. radius?: number;
  58144. tessellation?: number;
  58145. arc?: number;
  58146. updatable?: boolean;
  58147. sideOrientation?: number;
  58148. frontUVs?: Vector4;
  58149. backUVs?: Vector4;
  58150. }, scene?: Nullable<Scene>): Mesh;
  58151. /**
  58152. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58153. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58154. * * 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`)
  58155. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58156. * * 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
  58157. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58158. * * 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
  58159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58160. * @param name defines the name of the mesh
  58161. * @param options defines the options used to create the mesh
  58162. * @param scene defines the hosting scene
  58163. * @returns the icosahedron mesh
  58164. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58165. */
  58166. static CreateIcoSphere(name: string, options: {
  58167. radius?: number;
  58168. radiusX?: number;
  58169. radiusY?: number;
  58170. radiusZ?: number;
  58171. flat?: boolean;
  58172. subdivisions?: number;
  58173. sideOrientation?: number;
  58174. frontUVs?: Vector4;
  58175. backUVs?: Vector4;
  58176. updatable?: boolean;
  58177. }, scene?: Nullable<Scene>): Mesh;
  58178. /**
  58179. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58180. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58181. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58182. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58183. * * 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
  58184. * * 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
  58185. * * 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
  58186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58187. * * 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
  58188. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58189. * * 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
  58190. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58191. * * 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
  58192. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58194. * @param name defines the name of the mesh
  58195. * @param options defines the options used to create the mesh
  58196. * @param scene defines the hosting scene
  58197. * @returns the ribbon mesh
  58198. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58199. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58200. */
  58201. static CreateRibbon(name: string, options: {
  58202. pathArray: Vector3[][];
  58203. closeArray?: boolean;
  58204. closePath?: boolean;
  58205. offset?: number;
  58206. updatable?: boolean;
  58207. sideOrientation?: number;
  58208. frontUVs?: Vector4;
  58209. backUVs?: Vector4;
  58210. instance?: Mesh;
  58211. invertUV?: boolean;
  58212. uvs?: Vector2[];
  58213. colors?: Color4[];
  58214. }, scene?: Nullable<Scene>): Mesh;
  58215. /**
  58216. * Creates a cylinder or a cone mesh
  58217. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  58218. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  58219. * * 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.
  58220. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  58221. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  58222. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  58223. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  58224. * * 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).
  58225. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  58226. * * 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).
  58227. * * 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
  58228. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  58229. * * 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
  58230. * * 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.
  58231. * * If `enclose` is false, a ring surface is one element.
  58232. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  58233. * * 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
  58234. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58235. * * 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
  58236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58237. * @param name defines the name of the mesh
  58238. * @param options defines the options used to create the mesh
  58239. * @param scene defines the hosting scene
  58240. * @returns the cylinder mesh
  58241. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  58242. */
  58243. static CreateCylinder(name: string, options: {
  58244. height?: number;
  58245. diameterTop?: number;
  58246. diameterBottom?: number;
  58247. diameter?: number;
  58248. tessellation?: number;
  58249. subdivisions?: number;
  58250. arc?: number;
  58251. faceColors?: Color4[];
  58252. faceUV?: Vector4[];
  58253. updatable?: boolean;
  58254. hasRings?: boolean;
  58255. enclose?: boolean;
  58256. cap?: number;
  58257. sideOrientation?: number;
  58258. frontUVs?: Vector4;
  58259. backUVs?: Vector4;
  58260. }, scene?: Nullable<Scene>): Mesh;
  58261. /**
  58262. * Creates a torus mesh
  58263. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  58264. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  58265. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  58266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58267. * * 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
  58268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58269. * @param name defines the name of the mesh
  58270. * @param options defines the options used to create the mesh
  58271. * @param scene defines the hosting scene
  58272. * @returns the torus mesh
  58273. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  58274. */
  58275. static CreateTorus(name: string, options: {
  58276. diameter?: number;
  58277. thickness?: number;
  58278. tessellation?: number;
  58279. updatable?: boolean;
  58280. sideOrientation?: number;
  58281. frontUVs?: Vector4;
  58282. backUVs?: Vector4;
  58283. }, scene?: Nullable<Scene>): Mesh;
  58284. /**
  58285. * Creates a torus knot mesh
  58286. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58287. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58288. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58289. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58290. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58291. * * 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
  58292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58293. * @param name defines the name of the mesh
  58294. * @param options defines the options used to create the mesh
  58295. * @param scene defines the hosting scene
  58296. * @returns the torus knot mesh
  58297. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58298. */
  58299. static CreateTorusKnot(name: string, options: {
  58300. radius?: number;
  58301. tube?: number;
  58302. radialSegments?: number;
  58303. tubularSegments?: number;
  58304. p?: number;
  58305. q?: number;
  58306. updatable?: boolean;
  58307. sideOrientation?: number;
  58308. frontUVs?: Vector4;
  58309. backUVs?: Vector4;
  58310. }, scene?: Nullable<Scene>): Mesh;
  58311. /**
  58312. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  58313. * * 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
  58314. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  58315. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  58316. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  58317. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  58318. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  58319. * * 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
  58320. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  58321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58322. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  58323. * @param name defines the name of the new line system
  58324. * @param options defines the options used to create the line system
  58325. * @param scene defines the hosting scene
  58326. * @returns a new line system mesh
  58327. */
  58328. static CreateLineSystem(name: string, options: {
  58329. lines: Vector3[][];
  58330. updatable?: boolean;
  58331. instance?: Nullable<LinesMesh>;
  58332. colors?: Nullable<Color4[][]>;
  58333. useVertexAlpha?: boolean;
  58334. }, scene: Nullable<Scene>): LinesMesh;
  58335. /**
  58336. * Creates a line mesh
  58337. * 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
  58338. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58339. * * The parameter `points` is an array successive Vector3
  58340. * * 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
  58341. * * The optional parameter `colors` is an array of successive Color4, one per line point
  58342. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  58343. * * When updating an instance, remember that only point positions can change, not the number of points
  58344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58345. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  58346. * @param name defines the name of the new line system
  58347. * @param options defines the options used to create the line system
  58348. * @param scene defines the hosting scene
  58349. * @returns a new line mesh
  58350. */
  58351. static CreateLines(name: string, options: {
  58352. points: Vector3[];
  58353. updatable?: boolean;
  58354. instance?: Nullable<LinesMesh>;
  58355. colors?: Color4[];
  58356. useVertexAlpha?: boolean;
  58357. }, scene?: Nullable<Scene>): LinesMesh;
  58358. /**
  58359. * Creates a dashed line mesh
  58360. * * 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
  58361. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58362. * * The parameter `points` is an array successive Vector3
  58363. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  58364. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  58365. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  58366. * * 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
  58367. * * When updating an instance, remember that only point positions can change, not the number of points
  58368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58369. * @param name defines the name of the mesh
  58370. * @param options defines the options used to create the mesh
  58371. * @param scene defines the hosting scene
  58372. * @returns the dashed line mesh
  58373. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  58374. */
  58375. static CreateDashedLines(name: string, options: {
  58376. points: Vector3[];
  58377. dashSize?: number;
  58378. gapSize?: number;
  58379. dashNb?: number;
  58380. updatable?: boolean;
  58381. instance?: LinesMesh;
  58382. }, scene?: Nullable<Scene>): LinesMesh;
  58383. /**
  58384. * 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.
  58385. * * 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.
  58386. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58387. * * 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.
  58388. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58389. * * 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
  58390. * * 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
  58391. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58393. * * 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
  58394. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58396. * @param name defines the name of the mesh
  58397. * @param options defines the options used to create the mesh
  58398. * @param scene defines the hosting scene
  58399. * @returns the extruded shape mesh
  58400. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58401. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58402. */
  58403. static ExtrudeShape(name: string, options: {
  58404. shape: Vector3[];
  58405. path: Vector3[];
  58406. scale?: number;
  58407. rotation?: number;
  58408. cap?: number;
  58409. updatable?: boolean;
  58410. sideOrientation?: number;
  58411. frontUVs?: Vector4;
  58412. backUVs?: Vector4;
  58413. instance?: Mesh;
  58414. invertUV?: boolean;
  58415. }, scene?: Nullable<Scene>): Mesh;
  58416. /**
  58417. * Creates an custom extruded shape mesh.
  58418. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58419. * * 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.
  58420. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58421. * * 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
  58422. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58423. * * 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
  58424. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58425. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58426. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58427. * * 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
  58428. * * 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
  58429. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58431. * * 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
  58432. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58434. * @param name defines the name of the mesh
  58435. * @param options defines the options used to create the mesh
  58436. * @param scene defines the hosting scene
  58437. * @returns the custom extruded shape mesh
  58438. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58439. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58440. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58441. */
  58442. static ExtrudeShapeCustom(name: string, options: {
  58443. shape: Vector3[];
  58444. path: Vector3[];
  58445. scaleFunction?: any;
  58446. rotationFunction?: any;
  58447. ribbonCloseArray?: boolean;
  58448. ribbonClosePath?: boolean;
  58449. cap?: number;
  58450. updatable?: boolean;
  58451. sideOrientation?: number;
  58452. frontUVs?: Vector4;
  58453. backUVs?: Vector4;
  58454. instance?: Mesh;
  58455. invertUV?: boolean;
  58456. }, scene?: Nullable<Scene>): Mesh;
  58457. /**
  58458. * Creates lathe mesh.
  58459. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58460. * * 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
  58461. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58462. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58463. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58464. * * 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
  58465. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58466. * * 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
  58467. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58468. * * 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
  58469. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58471. * @param name defines the name of the mesh
  58472. * @param options defines the options used to create the mesh
  58473. * @param scene defines the hosting scene
  58474. * @returns the lathe mesh
  58475. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58476. */
  58477. static CreateLathe(name: string, options: {
  58478. shape: Vector3[];
  58479. radius?: number;
  58480. tessellation?: number;
  58481. clip?: number;
  58482. arc?: number;
  58483. closed?: boolean;
  58484. updatable?: boolean;
  58485. sideOrientation?: number;
  58486. frontUVs?: Vector4;
  58487. backUVs?: Vector4;
  58488. cap?: number;
  58489. invertUV?: boolean;
  58490. }, scene?: Nullable<Scene>): Mesh;
  58491. /**
  58492. * Creates a tiled plane mesh
  58493. * * You can set a limited pattern arrangement with the tiles
  58494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58495. * * 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
  58496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58497. * @param name defines the name of the mesh
  58498. * @param options defines the options used to create the mesh
  58499. * @param scene defines the hosting scene
  58500. * @returns the plane mesh
  58501. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58502. */
  58503. static CreateTiledPlane(name: string, options: {
  58504. pattern?: number;
  58505. tileSize?: number;
  58506. tileWidth?: number;
  58507. tileHeight?: number;
  58508. size?: number;
  58509. width?: number;
  58510. height?: number;
  58511. alignHorizontal?: number;
  58512. alignVertical?: number;
  58513. sideOrientation?: number;
  58514. frontUVs?: Vector4;
  58515. backUVs?: Vector4;
  58516. updatable?: boolean;
  58517. }, scene?: Nullable<Scene>): Mesh;
  58518. /**
  58519. * Creates a plane mesh
  58520. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  58521. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  58522. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  58523. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58524. * * 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
  58525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58526. * @param name defines the name of the mesh
  58527. * @param options defines the options used to create the mesh
  58528. * @param scene defines the hosting scene
  58529. * @returns the plane mesh
  58530. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58531. */
  58532. static CreatePlane(name: string, options: {
  58533. size?: number;
  58534. width?: number;
  58535. height?: number;
  58536. sideOrientation?: number;
  58537. frontUVs?: Vector4;
  58538. backUVs?: Vector4;
  58539. updatable?: boolean;
  58540. sourcePlane?: Plane;
  58541. }, scene?: Nullable<Scene>): Mesh;
  58542. /**
  58543. * Creates a ground mesh
  58544. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  58545. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  58546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58547. * @param name defines the name of the mesh
  58548. * @param options defines the options used to create the mesh
  58549. * @param scene defines the hosting scene
  58550. * @returns the ground mesh
  58551. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  58552. */
  58553. static CreateGround(name: string, options: {
  58554. width?: number;
  58555. height?: number;
  58556. subdivisions?: number;
  58557. subdivisionsX?: number;
  58558. subdivisionsY?: number;
  58559. updatable?: boolean;
  58560. }, scene?: Nullable<Scene>): Mesh;
  58561. /**
  58562. * Creates a tiled ground mesh
  58563. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  58564. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  58565. * * 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
  58566. * * 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
  58567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58568. * @param name defines the name of the mesh
  58569. * @param options defines the options used to create the mesh
  58570. * @param scene defines the hosting scene
  58571. * @returns the tiled ground mesh
  58572. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  58573. */
  58574. static CreateTiledGround(name: string, options: {
  58575. xmin: number;
  58576. zmin: number;
  58577. xmax: number;
  58578. zmax: number;
  58579. subdivisions?: {
  58580. w: number;
  58581. h: number;
  58582. };
  58583. precision?: {
  58584. w: number;
  58585. h: number;
  58586. };
  58587. updatable?: boolean;
  58588. }, scene?: Nullable<Scene>): Mesh;
  58589. /**
  58590. * Creates a ground mesh from a height map
  58591. * * The parameter `url` sets the URL of the height map image resource.
  58592. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  58593. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  58594. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  58595. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  58596. * * 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.
  58597. * * 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).
  58598. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  58599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58600. * @param name defines the name of the mesh
  58601. * @param url defines the url to the height map
  58602. * @param options defines the options used to create the mesh
  58603. * @param scene defines the hosting scene
  58604. * @returns the ground mesh
  58605. * @see https://doc.babylonjs.com/babylon101/height_map
  58606. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  58607. */
  58608. static CreateGroundFromHeightMap(name: string, url: string, options: {
  58609. width?: number;
  58610. height?: number;
  58611. subdivisions?: number;
  58612. minHeight?: number;
  58613. maxHeight?: number;
  58614. colorFilter?: Color3;
  58615. alphaFilter?: number;
  58616. updatable?: boolean;
  58617. onReady?: (mesh: GroundMesh) => void;
  58618. }, scene?: Nullable<Scene>): GroundMesh;
  58619. /**
  58620. * Creates a polygon mesh
  58621. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58622. * * 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
  58623. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58625. * * 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)
  58626. * * Remember you can only change the shape positions, not their number when updating a polygon
  58627. * @param name defines the name of the mesh
  58628. * @param options defines the options used to create the mesh
  58629. * @param scene defines the hosting scene
  58630. * @param earcutInjection can be used to inject your own earcut reference
  58631. * @returns the polygon mesh
  58632. */
  58633. static CreatePolygon(name: string, options: {
  58634. shape: Vector3[];
  58635. holes?: Vector3[][];
  58636. depth?: number;
  58637. faceUV?: Vector4[];
  58638. faceColors?: Color4[];
  58639. updatable?: boolean;
  58640. sideOrientation?: number;
  58641. frontUVs?: Vector4;
  58642. backUVs?: Vector4;
  58643. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58644. /**
  58645. * Creates an extruded polygon mesh, with depth in the Y direction.
  58646. * * 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)
  58647. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58648. * @param name defines the name of the mesh
  58649. * @param options defines the options used to create the mesh
  58650. * @param scene defines the hosting scene
  58651. * @param earcutInjection can be used to inject your own earcut reference
  58652. * @returns the polygon mesh
  58653. */
  58654. static ExtrudePolygon(name: string, options: {
  58655. shape: Vector3[];
  58656. holes?: Vector3[][];
  58657. depth?: number;
  58658. faceUV?: Vector4[];
  58659. faceColors?: Color4[];
  58660. updatable?: boolean;
  58661. sideOrientation?: number;
  58662. frontUVs?: Vector4;
  58663. backUVs?: Vector4;
  58664. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58665. /**
  58666. * Creates a tube mesh.
  58667. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58668. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58669. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58670. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58671. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58672. * * 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)
  58673. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58674. * * 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
  58675. * * 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
  58676. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58677. * * 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
  58678. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58680. * @param name defines the name of the mesh
  58681. * @param options defines the options used to create the mesh
  58682. * @param scene defines the hosting scene
  58683. * @returns the tube mesh
  58684. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58685. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58686. */
  58687. static CreateTube(name: string, options: {
  58688. path: Vector3[];
  58689. radius?: number;
  58690. tessellation?: number;
  58691. radiusFunction?: {
  58692. (i: number, distance: number): number;
  58693. };
  58694. cap?: number;
  58695. arc?: number;
  58696. updatable?: boolean;
  58697. sideOrientation?: number;
  58698. frontUVs?: Vector4;
  58699. backUVs?: Vector4;
  58700. instance?: Mesh;
  58701. invertUV?: boolean;
  58702. }, scene?: Nullable<Scene>): Mesh;
  58703. /**
  58704. * Creates a polyhedron mesh
  58705. * * 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
  58706. * * The parameter `size` (positive float, default 1) sets the polygon size
  58707. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58708. * * 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`
  58709. * * 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
  58710. * * 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)`)
  58711. * * 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
  58712. * * 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
  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 polyhedron mesh
  58720. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58721. */
  58722. static CreatePolyhedron(name: string, options: {
  58723. type?: number;
  58724. size?: number;
  58725. sizeX?: number;
  58726. sizeY?: number;
  58727. sizeZ?: number;
  58728. custom?: any;
  58729. faceUV?: Vector4[];
  58730. faceColors?: Color4[];
  58731. flat?: boolean;
  58732. updatable?: boolean;
  58733. sideOrientation?: number;
  58734. frontUVs?: Vector4;
  58735. backUVs?: Vector4;
  58736. }, scene?: Nullable<Scene>): Mesh;
  58737. /**
  58738. * Creates a decal mesh.
  58739. * 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
  58740. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58741. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58742. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58743. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58744. * @param name defines the name of the mesh
  58745. * @param sourceMesh defines the mesh where the decal must be applied
  58746. * @param options defines the options used to create the mesh
  58747. * @param scene defines the hosting scene
  58748. * @returns the decal mesh
  58749. * @see https://doc.babylonjs.com/how_to/decals
  58750. */
  58751. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58752. position?: Vector3;
  58753. normal?: Vector3;
  58754. size?: Vector3;
  58755. angle?: number;
  58756. }): Mesh;
  58757. }
  58758. }
  58759. declare module BABYLON {
  58760. /**
  58761. * A simplifier interface for future simplification implementations
  58762. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58763. */
  58764. export interface ISimplifier {
  58765. /**
  58766. * Simplification of a given mesh according to the given settings.
  58767. * Since this requires computation, it is assumed that the function runs async.
  58768. * @param settings The settings of the simplification, including quality and distance
  58769. * @param successCallback A callback that will be called after the mesh was simplified.
  58770. * @param errorCallback in case of an error, this callback will be called. optional.
  58771. */
  58772. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  58773. }
  58774. /**
  58775. * Expected simplification settings.
  58776. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  58777. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58778. */
  58779. export interface ISimplificationSettings {
  58780. /**
  58781. * Gets or sets the expected quality
  58782. */
  58783. quality: number;
  58784. /**
  58785. * Gets or sets the distance when this optimized version should be used
  58786. */
  58787. distance: number;
  58788. /**
  58789. * Gets an already optimized mesh
  58790. */
  58791. optimizeMesh?: boolean;
  58792. }
  58793. /**
  58794. * Class used to specify simplification options
  58795. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58796. */
  58797. export class SimplificationSettings implements ISimplificationSettings {
  58798. /** expected quality */
  58799. quality: number;
  58800. /** distance when this optimized version should be used */
  58801. distance: number;
  58802. /** already optimized mesh */
  58803. optimizeMesh?: boolean | undefined;
  58804. /**
  58805. * Creates a SimplificationSettings
  58806. * @param quality expected quality
  58807. * @param distance distance when this optimized version should be used
  58808. * @param optimizeMesh already optimized mesh
  58809. */
  58810. constructor(
  58811. /** expected quality */
  58812. quality: number,
  58813. /** distance when this optimized version should be used */
  58814. distance: number,
  58815. /** already optimized mesh */
  58816. optimizeMesh?: boolean | undefined);
  58817. }
  58818. /**
  58819. * Interface used to define a simplification task
  58820. */
  58821. export interface ISimplificationTask {
  58822. /**
  58823. * Array of settings
  58824. */
  58825. settings: Array<ISimplificationSettings>;
  58826. /**
  58827. * Simplification type
  58828. */
  58829. simplificationType: SimplificationType;
  58830. /**
  58831. * Mesh to simplify
  58832. */
  58833. mesh: Mesh;
  58834. /**
  58835. * Callback called on success
  58836. */
  58837. successCallback?: () => void;
  58838. /**
  58839. * Defines if parallel processing can be used
  58840. */
  58841. parallelProcessing: boolean;
  58842. }
  58843. /**
  58844. * Queue used to order the simplification tasks
  58845. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58846. */
  58847. export class SimplificationQueue {
  58848. private _simplificationArray;
  58849. /**
  58850. * Gets a boolean indicating that the process is still running
  58851. */
  58852. running: boolean;
  58853. /**
  58854. * Creates a new queue
  58855. */
  58856. constructor();
  58857. /**
  58858. * Adds a new simplification task
  58859. * @param task defines a task to add
  58860. */
  58861. addTask(task: ISimplificationTask): void;
  58862. /**
  58863. * Execute next task
  58864. */
  58865. executeNext(): void;
  58866. /**
  58867. * Execute a simplification task
  58868. * @param task defines the task to run
  58869. */
  58870. runSimplification(task: ISimplificationTask): void;
  58871. private getSimplifier;
  58872. }
  58873. /**
  58874. * The implemented types of simplification
  58875. * At the moment only Quadratic Error Decimation is implemented
  58876. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58877. */
  58878. export enum SimplificationType {
  58879. /** Quadratic error decimation */
  58880. QUADRATIC = 0
  58881. }
  58882. }
  58883. declare module BABYLON {
  58884. interface Scene {
  58885. /** @hidden (Backing field) */
  58886. _simplificationQueue: SimplificationQueue;
  58887. /**
  58888. * Gets or sets the simplification queue attached to the scene
  58889. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58890. */
  58891. simplificationQueue: SimplificationQueue;
  58892. }
  58893. interface Mesh {
  58894. /**
  58895. * Simplify the mesh according to the given array of settings.
  58896. * Function will return immediately and will simplify async
  58897. * @param settings a collection of simplification settings
  58898. * @param parallelProcessing should all levels calculate parallel or one after the other
  58899. * @param simplificationType the type of simplification to run
  58900. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  58901. * @returns the current mesh
  58902. */
  58903. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  58904. }
  58905. /**
  58906. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  58907. * created in a scene
  58908. */
  58909. export class SimplicationQueueSceneComponent implements ISceneComponent {
  58910. /**
  58911. * The component name helpfull to identify the component in the list of scene components.
  58912. */
  58913. readonly name: string;
  58914. /**
  58915. * The scene the component belongs to.
  58916. */
  58917. scene: Scene;
  58918. /**
  58919. * Creates a new instance of the component for the given scene
  58920. * @param scene Defines the scene to register the component in
  58921. */
  58922. constructor(scene: Scene);
  58923. /**
  58924. * Registers the component in a given scene
  58925. */
  58926. register(): void;
  58927. /**
  58928. * Rebuilds the elements related to this component in case of
  58929. * context lost for instance.
  58930. */
  58931. rebuild(): void;
  58932. /**
  58933. * Disposes the component and the associated ressources
  58934. */
  58935. dispose(): void;
  58936. private _beforeCameraUpdate;
  58937. }
  58938. }
  58939. declare module BABYLON {
  58940. /**
  58941. * Navigation plugin interface to add navigation constrained by a navigation mesh
  58942. */
  58943. export interface INavigationEnginePlugin {
  58944. /**
  58945. * plugin name
  58946. */
  58947. name: string;
  58948. /**
  58949. * Creates a navigation mesh
  58950. * @param meshes array of all the geometry used to compute the navigatio mesh
  58951. * @param parameters bunch of parameters used to filter geometry
  58952. */
  58953. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58954. /**
  58955. * Create a navigation mesh debug mesh
  58956. * @param scene is where the mesh will be added
  58957. * @returns debug display mesh
  58958. */
  58959. createDebugNavMesh(scene: Scene): Mesh;
  58960. /**
  58961. * Get a navigation mesh constrained position, closest to the parameter position
  58962. * @param position world position
  58963. * @returns the closest point to position constrained by the navigation mesh
  58964. */
  58965. getClosestPoint(position: Vector3): Vector3;
  58966. /**
  58967. * Get a navigation mesh constrained position, within a particular radius
  58968. * @param position world position
  58969. * @param maxRadius the maximum distance to the constrained world position
  58970. * @returns the closest point to position constrained by the navigation mesh
  58971. */
  58972. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58973. /**
  58974. * Compute the final position from a segment made of destination-position
  58975. * @param position world position
  58976. * @param destination world position
  58977. * @returns the resulting point along the navmesh
  58978. */
  58979. moveAlong(position: Vector3, destination: Vector3): Vector3;
  58980. /**
  58981. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58982. * @param start world position
  58983. * @param end world position
  58984. * @returns array containing world position composing the path
  58985. */
  58986. computePath(start: Vector3, end: Vector3): Vector3[];
  58987. /**
  58988. * If this plugin is supported
  58989. * @returns true if plugin is supported
  58990. */
  58991. isSupported(): boolean;
  58992. /**
  58993. * Create a new Crowd so you can add agents
  58994. * @param maxAgents the maximum agent count in the crowd
  58995. * @param maxAgentRadius the maximum radius an agent can have
  58996. * @param scene to attach the crowd to
  58997. * @returns the crowd you can add agents to
  58998. */
  58999. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59000. /**
  59001. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59002. * The queries will try to find a solution within those bounds
  59003. * default is (1,1,1)
  59004. * @param extent x,y,z value that define the extent around the queries point of reference
  59005. */
  59006. setDefaultQueryExtent(extent: Vector3): void;
  59007. /**
  59008. * Get the Bounding box extent specified by setDefaultQueryExtent
  59009. * @returns the box extent values
  59010. */
  59011. getDefaultQueryExtent(): Vector3;
  59012. /**
  59013. * Release all resources
  59014. */
  59015. dispose(): void;
  59016. }
  59017. /**
  59018. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  59019. */
  59020. export interface ICrowd {
  59021. /**
  59022. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59023. * You can attach anything to that node. The node position is updated in the scene update tick.
  59024. * @param pos world position that will be constrained by the navigation mesh
  59025. * @param parameters agent parameters
  59026. * @param transform hooked to the agent that will be update by the scene
  59027. * @returns agent index
  59028. */
  59029. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59030. /**
  59031. * Returns the agent position in world space
  59032. * @param index agent index returned by addAgent
  59033. * @returns world space position
  59034. */
  59035. getAgentPosition(index: number): Vector3;
  59036. /**
  59037. * Gets the agent velocity in world space
  59038. * @param index agent index returned by addAgent
  59039. * @returns world space velocity
  59040. */
  59041. getAgentVelocity(index: number): Vector3;
  59042. /**
  59043. * remove a particular agent previously created
  59044. * @param index agent index returned by addAgent
  59045. */
  59046. removeAgent(index: number): void;
  59047. /**
  59048. * get the list of all agents attached to this crowd
  59049. * @returns list of agent indices
  59050. */
  59051. getAgents(): number[];
  59052. /**
  59053. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59054. * @param deltaTime in seconds
  59055. */
  59056. update(deltaTime: number): void;
  59057. /**
  59058. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59059. * @param index agent index returned by addAgent
  59060. * @param destination targeted world position
  59061. */
  59062. agentGoto(index: number, destination: Vector3): void;
  59063. /**
  59064. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59065. * The queries will try to find a solution within those bounds
  59066. * default is (1,1,1)
  59067. * @param extent x,y,z value that define the extent around the queries point of reference
  59068. */
  59069. setDefaultQueryExtent(extent: Vector3): void;
  59070. /**
  59071. * Get the Bounding box extent specified by setDefaultQueryExtent
  59072. * @returns the box extent values
  59073. */
  59074. getDefaultQueryExtent(): Vector3;
  59075. /**
  59076. * Release all resources
  59077. */
  59078. dispose(): void;
  59079. }
  59080. /**
  59081. * Configures an agent
  59082. */
  59083. export interface IAgentParameters {
  59084. /**
  59085. * Agent radius. [Limit: >= 0]
  59086. */
  59087. radius: number;
  59088. /**
  59089. * Agent height. [Limit: > 0]
  59090. */
  59091. height: number;
  59092. /**
  59093. * Maximum allowed acceleration. [Limit: >= 0]
  59094. */
  59095. maxAcceleration: number;
  59096. /**
  59097. * Maximum allowed speed. [Limit: >= 0]
  59098. */
  59099. maxSpeed: number;
  59100. /**
  59101. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  59102. */
  59103. collisionQueryRange: number;
  59104. /**
  59105. * The path visibility optimization range. [Limit: > 0]
  59106. */
  59107. pathOptimizationRange: number;
  59108. /**
  59109. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  59110. */
  59111. separationWeight: number;
  59112. }
  59113. /**
  59114. * Configures the navigation mesh creation
  59115. */
  59116. export interface INavMeshParameters {
  59117. /**
  59118. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  59119. */
  59120. cs: number;
  59121. /**
  59122. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  59123. */
  59124. ch: number;
  59125. /**
  59126. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  59127. */
  59128. walkableSlopeAngle: number;
  59129. /**
  59130. * Minimum floor to 'ceiling' height that will still allow the floor area to
  59131. * be considered walkable. [Limit: >= 3] [Units: vx]
  59132. */
  59133. walkableHeight: number;
  59134. /**
  59135. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  59136. */
  59137. walkableClimb: number;
  59138. /**
  59139. * The distance to erode/shrink the walkable area of the heightfield away from
  59140. * obstructions. [Limit: >=0] [Units: vx]
  59141. */
  59142. walkableRadius: number;
  59143. /**
  59144. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  59145. */
  59146. maxEdgeLen: number;
  59147. /**
  59148. * The maximum distance a simplfied contour's border edges should deviate
  59149. * the original raw contour. [Limit: >=0] [Units: vx]
  59150. */
  59151. maxSimplificationError: number;
  59152. /**
  59153. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  59154. */
  59155. minRegionArea: number;
  59156. /**
  59157. * Any regions with a span count smaller than this value will, if possible,
  59158. * be merged with larger regions. [Limit: >=0] [Units: vx]
  59159. */
  59160. mergeRegionArea: number;
  59161. /**
  59162. * The maximum number of vertices allowed for polygons generated during the
  59163. * contour to polygon conversion process. [Limit: >= 3]
  59164. */
  59165. maxVertsPerPoly: number;
  59166. /**
  59167. * Sets the sampling distance to use when generating the detail mesh.
  59168. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  59169. */
  59170. detailSampleDist: number;
  59171. /**
  59172. * The maximum distance the detail mesh surface should deviate from heightfield
  59173. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  59174. */
  59175. detailSampleMaxError: number;
  59176. }
  59177. }
  59178. declare module BABYLON {
  59179. /**
  59180. * RecastJS navigation plugin
  59181. */
  59182. export class RecastJSPlugin implements INavigationEnginePlugin {
  59183. /**
  59184. * Reference to the Recast library
  59185. */
  59186. bjsRECAST: any;
  59187. /**
  59188. * plugin name
  59189. */
  59190. name: string;
  59191. /**
  59192. * the first navmesh created. We might extend this to support multiple navmeshes
  59193. */
  59194. navMesh: any;
  59195. /**
  59196. * Initializes the recastJS plugin
  59197. * @param recastInjection can be used to inject your own recast reference
  59198. */
  59199. constructor(recastInjection?: any);
  59200. /**
  59201. * Creates a navigation mesh
  59202. * @param meshes array of all the geometry used to compute the navigatio mesh
  59203. * @param parameters bunch of parameters used to filter geometry
  59204. */
  59205. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59206. /**
  59207. * Create a navigation mesh debug mesh
  59208. * @param scene is where the mesh will be added
  59209. * @returns debug display mesh
  59210. */
  59211. createDebugNavMesh(scene: Scene): Mesh;
  59212. /**
  59213. * Get a navigation mesh constrained position, closest to the parameter position
  59214. * @param position world position
  59215. * @returns the closest point to position constrained by the navigation mesh
  59216. */
  59217. getClosestPoint(position: Vector3): Vector3;
  59218. /**
  59219. * Get a navigation mesh constrained position, within a particular radius
  59220. * @param position world position
  59221. * @param maxRadius the maximum distance to the constrained world position
  59222. * @returns the closest point to position constrained by the navigation mesh
  59223. */
  59224. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59225. /**
  59226. * Compute the final position from a segment made of destination-position
  59227. * @param position world position
  59228. * @param destination world position
  59229. * @returns the resulting point along the navmesh
  59230. */
  59231. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59232. /**
  59233. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59234. * @param start world position
  59235. * @param end world position
  59236. * @returns array containing world position composing the path
  59237. */
  59238. computePath(start: Vector3, end: Vector3): Vector3[];
  59239. /**
  59240. * Create a new Crowd so you can add agents
  59241. * @param maxAgents the maximum agent count in the crowd
  59242. * @param maxAgentRadius the maximum radius an agent can have
  59243. * @param scene to attach the crowd to
  59244. * @returns the crowd you can add agents to
  59245. */
  59246. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59247. /**
  59248. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59249. * The queries will try to find a solution within those bounds
  59250. * default is (1,1,1)
  59251. * @param extent x,y,z value that define the extent around the queries point of reference
  59252. */
  59253. setDefaultQueryExtent(extent: Vector3): void;
  59254. /**
  59255. * Get the Bounding box extent specified by setDefaultQueryExtent
  59256. * @returns the box extent values
  59257. */
  59258. getDefaultQueryExtent(): Vector3;
  59259. /**
  59260. * Disposes
  59261. */
  59262. dispose(): void;
  59263. /**
  59264. * If this plugin is supported
  59265. * @returns true if plugin is supported
  59266. */
  59267. isSupported(): boolean;
  59268. }
  59269. /**
  59270. * Recast detour crowd implementation
  59271. */
  59272. export class RecastJSCrowd implements ICrowd {
  59273. /**
  59274. * Recast/detour plugin
  59275. */
  59276. bjsRECASTPlugin: RecastJSPlugin;
  59277. /**
  59278. * Link to the detour crowd
  59279. */
  59280. recastCrowd: any;
  59281. /**
  59282. * One transform per agent
  59283. */
  59284. transforms: TransformNode[];
  59285. /**
  59286. * All agents created
  59287. */
  59288. agents: number[];
  59289. /**
  59290. * Link to the scene is kept to unregister the crowd from the scene
  59291. */
  59292. private _scene;
  59293. /**
  59294. * Observer for crowd updates
  59295. */
  59296. private _onBeforeAnimationsObserver;
  59297. /**
  59298. * Constructor
  59299. * @param plugin recastJS plugin
  59300. * @param maxAgents the maximum agent count in the crowd
  59301. * @param maxAgentRadius the maximum radius an agent can have
  59302. * @param scene to attach the crowd to
  59303. * @returns the crowd you can add agents to
  59304. */
  59305. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  59306. /**
  59307. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59308. * You can attach anything to that node. The node position is updated in the scene update tick.
  59309. * @param pos world position that will be constrained by the navigation mesh
  59310. * @param parameters agent parameters
  59311. * @param transform hooked to the agent that will be update by the scene
  59312. * @returns agent index
  59313. */
  59314. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59315. /**
  59316. * Returns the agent position in world space
  59317. * @param index agent index returned by addAgent
  59318. * @returns world space position
  59319. */
  59320. getAgentPosition(index: number): Vector3;
  59321. /**
  59322. * Returns the agent velocity in world space
  59323. * @param index agent index returned by addAgent
  59324. * @returns world space velocity
  59325. */
  59326. getAgentVelocity(index: number): Vector3;
  59327. /**
  59328. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59329. * @param index agent index returned by addAgent
  59330. * @param destination targeted world position
  59331. */
  59332. agentGoto(index: number, destination: Vector3): void;
  59333. /**
  59334. * remove a particular agent previously created
  59335. * @param index agent index returned by addAgent
  59336. */
  59337. removeAgent(index: number): void;
  59338. /**
  59339. * get the list of all agents attached to this crowd
  59340. * @returns list of agent indices
  59341. */
  59342. getAgents(): number[];
  59343. /**
  59344. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59345. * @param deltaTime in seconds
  59346. */
  59347. update(deltaTime: number): void;
  59348. /**
  59349. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59350. * The queries will try to find a solution within those bounds
  59351. * default is (1,1,1)
  59352. * @param extent x,y,z value that define the extent around the queries point of reference
  59353. */
  59354. setDefaultQueryExtent(extent: Vector3): void;
  59355. /**
  59356. * Get the Bounding box extent specified by setDefaultQueryExtent
  59357. * @returns the box extent values
  59358. */
  59359. getDefaultQueryExtent(): Vector3;
  59360. /**
  59361. * Release all resources
  59362. */
  59363. dispose(): void;
  59364. }
  59365. }
  59366. declare module BABYLON {
  59367. /**
  59368. * Class used to enable access to IndexedDB
  59369. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  59370. */
  59371. export class Database implements IOfflineProvider {
  59372. private _callbackManifestChecked;
  59373. private _currentSceneUrl;
  59374. private _db;
  59375. private _enableSceneOffline;
  59376. private _enableTexturesOffline;
  59377. private _manifestVersionFound;
  59378. private _mustUpdateRessources;
  59379. private _hasReachedQuota;
  59380. private _isSupported;
  59381. private _idbFactory;
  59382. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  59383. private static IsUASupportingBlobStorage;
  59384. /**
  59385. * Gets a boolean indicating if Database storate is enabled (off by default)
  59386. */
  59387. static IDBStorageEnabled: boolean;
  59388. /**
  59389. * Gets a boolean indicating if scene must be saved in the database
  59390. */
  59391. readonly enableSceneOffline: boolean;
  59392. /**
  59393. * Gets a boolean indicating if textures must be saved in the database
  59394. */
  59395. readonly enableTexturesOffline: boolean;
  59396. /**
  59397. * Creates a new Database
  59398. * @param urlToScene defines the url to load the scene
  59399. * @param callbackManifestChecked defines the callback to use when manifest is checked
  59400. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  59401. */
  59402. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  59403. private static _ParseURL;
  59404. private static _ReturnFullUrlLocation;
  59405. private _checkManifestFile;
  59406. /**
  59407. * Open the database and make it available
  59408. * @param successCallback defines the callback to call on success
  59409. * @param errorCallback defines the callback to call on error
  59410. */
  59411. open(successCallback: () => void, errorCallback: () => void): void;
  59412. /**
  59413. * Loads an image from the database
  59414. * @param url defines the url to load from
  59415. * @param image defines the target DOM image
  59416. */
  59417. loadImage(url: string, image: HTMLImageElement): void;
  59418. private _loadImageFromDBAsync;
  59419. private _saveImageIntoDBAsync;
  59420. private _checkVersionFromDB;
  59421. private _loadVersionFromDBAsync;
  59422. private _saveVersionIntoDBAsync;
  59423. /**
  59424. * Loads a file from database
  59425. * @param url defines the URL to load from
  59426. * @param sceneLoaded defines a callback to call on success
  59427. * @param progressCallBack defines a callback to call when progress changed
  59428. * @param errorCallback defines a callback to call on error
  59429. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  59430. */
  59431. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  59432. private _loadFileAsync;
  59433. private _saveFileAsync;
  59434. /**
  59435. * Validates if xhr data is correct
  59436. * @param xhr defines the request to validate
  59437. * @param dataType defines the expected data type
  59438. * @returns true if data is correct
  59439. */
  59440. private static _ValidateXHRData;
  59441. }
  59442. }
  59443. declare module BABYLON {
  59444. /** @hidden */
  59445. export var gpuUpdateParticlesPixelShader: {
  59446. name: string;
  59447. shader: string;
  59448. };
  59449. }
  59450. declare module BABYLON {
  59451. /** @hidden */
  59452. export var gpuUpdateParticlesVertexShader: {
  59453. name: string;
  59454. shader: string;
  59455. };
  59456. }
  59457. declare module BABYLON {
  59458. /** @hidden */
  59459. export var clipPlaneFragmentDeclaration2: {
  59460. name: string;
  59461. shader: string;
  59462. };
  59463. }
  59464. declare module BABYLON {
  59465. /** @hidden */
  59466. export var gpuRenderParticlesPixelShader: {
  59467. name: string;
  59468. shader: string;
  59469. };
  59470. }
  59471. declare module BABYLON {
  59472. /** @hidden */
  59473. export var clipPlaneVertexDeclaration2: {
  59474. name: string;
  59475. shader: string;
  59476. };
  59477. }
  59478. declare module BABYLON {
  59479. /** @hidden */
  59480. export var gpuRenderParticlesVertexShader: {
  59481. name: string;
  59482. shader: string;
  59483. };
  59484. }
  59485. declare module BABYLON {
  59486. /**
  59487. * This represents a GPU particle system in Babylon
  59488. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  59489. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  59490. */
  59491. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  59492. /**
  59493. * The layer mask we are rendering the particles through.
  59494. */
  59495. layerMask: number;
  59496. private _capacity;
  59497. private _activeCount;
  59498. private _currentActiveCount;
  59499. private _accumulatedCount;
  59500. private _renderEffect;
  59501. private _updateEffect;
  59502. private _buffer0;
  59503. private _buffer1;
  59504. private _spriteBuffer;
  59505. private _updateVAO;
  59506. private _renderVAO;
  59507. private _targetIndex;
  59508. private _sourceBuffer;
  59509. private _targetBuffer;
  59510. private _engine;
  59511. private _currentRenderId;
  59512. private _started;
  59513. private _stopped;
  59514. private _timeDelta;
  59515. private _randomTexture;
  59516. private _randomTexture2;
  59517. private _attributesStrideSize;
  59518. private _updateEffectOptions;
  59519. private _randomTextureSize;
  59520. private _actualFrame;
  59521. private readonly _rawTextureWidth;
  59522. /**
  59523. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  59524. */
  59525. static readonly IsSupported: boolean;
  59526. /**
  59527. * An event triggered when the system is disposed.
  59528. */
  59529. onDisposeObservable: Observable<GPUParticleSystem>;
  59530. /**
  59531. * Gets the maximum number of particles active at the same time.
  59532. * @returns The max number of active particles.
  59533. */
  59534. getCapacity(): number;
  59535. /**
  59536. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  59537. * to override the particles.
  59538. */
  59539. forceDepthWrite: boolean;
  59540. /**
  59541. * Gets or set the number of active particles
  59542. */
  59543. activeParticleCount: number;
  59544. private _preWarmDone;
  59545. /**
  59546. * Is this system ready to be used/rendered
  59547. * @return true if the system is ready
  59548. */
  59549. isReady(): boolean;
  59550. /**
  59551. * Gets if the system has been started. (Note: this will still be true after stop is called)
  59552. * @returns True if it has been started, otherwise false.
  59553. */
  59554. isStarted(): boolean;
  59555. /**
  59556. * Starts the particle system and begins to emit
  59557. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  59558. */
  59559. start(delay?: number): void;
  59560. /**
  59561. * Stops the particle system.
  59562. */
  59563. stop(): void;
  59564. /**
  59565. * Remove all active particles
  59566. */
  59567. reset(): void;
  59568. /**
  59569. * Returns the string "GPUParticleSystem"
  59570. * @returns a string containing the class name
  59571. */
  59572. getClassName(): string;
  59573. private _colorGradientsTexture;
  59574. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  59575. /**
  59576. * Adds a new color gradient
  59577. * @param gradient defines the gradient to use (between 0 and 1)
  59578. * @param color1 defines the color to affect to the specified gradient
  59579. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  59580. * @returns the current particle system
  59581. */
  59582. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  59583. /**
  59584. * Remove a specific color gradient
  59585. * @param gradient defines the gradient to remove
  59586. * @returns the current particle system
  59587. */
  59588. removeColorGradient(gradient: number): GPUParticleSystem;
  59589. private _angularSpeedGradientsTexture;
  59590. private _sizeGradientsTexture;
  59591. private _velocityGradientsTexture;
  59592. private _limitVelocityGradientsTexture;
  59593. private _dragGradientsTexture;
  59594. private _addFactorGradient;
  59595. /**
  59596. * Adds a new size gradient
  59597. * @param gradient defines the gradient to use (between 0 and 1)
  59598. * @param factor defines the size factor to affect to the specified gradient
  59599. * @returns the current particle system
  59600. */
  59601. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  59602. /**
  59603. * Remove a specific size gradient
  59604. * @param gradient defines the gradient to remove
  59605. * @returns the current particle system
  59606. */
  59607. removeSizeGradient(gradient: number): GPUParticleSystem;
  59608. /**
  59609. * Adds a new angular speed gradient
  59610. * @param gradient defines the gradient to use (between 0 and 1)
  59611. * @param factor defines the angular speed to affect to the specified gradient
  59612. * @returns the current particle system
  59613. */
  59614. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  59615. /**
  59616. * Remove a specific angular speed gradient
  59617. * @param gradient defines the gradient to remove
  59618. * @returns the current particle system
  59619. */
  59620. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  59621. /**
  59622. * Adds a new velocity gradient
  59623. * @param gradient defines the gradient to use (between 0 and 1)
  59624. * @param factor defines the velocity to affect to the specified gradient
  59625. * @returns the current particle system
  59626. */
  59627. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59628. /**
  59629. * Remove a specific velocity gradient
  59630. * @param gradient defines the gradient to remove
  59631. * @returns the current particle system
  59632. */
  59633. removeVelocityGradient(gradient: number): GPUParticleSystem;
  59634. /**
  59635. * Adds a new limit velocity gradient
  59636. * @param gradient defines the gradient to use (between 0 and 1)
  59637. * @param factor defines the limit velocity value to affect to the specified gradient
  59638. * @returns the current particle system
  59639. */
  59640. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59641. /**
  59642. * Remove a specific limit velocity gradient
  59643. * @param gradient defines the gradient to remove
  59644. * @returns the current particle system
  59645. */
  59646. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  59647. /**
  59648. * Adds a new drag gradient
  59649. * @param gradient defines the gradient to use (between 0 and 1)
  59650. * @param factor defines the drag value to affect to the specified gradient
  59651. * @returns the current particle system
  59652. */
  59653. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  59654. /**
  59655. * Remove a specific drag gradient
  59656. * @param gradient defines the gradient to remove
  59657. * @returns the current particle system
  59658. */
  59659. removeDragGradient(gradient: number): GPUParticleSystem;
  59660. /**
  59661. * Not supported by GPUParticleSystem
  59662. * @param gradient defines the gradient to use (between 0 and 1)
  59663. * @param factor defines the emit rate value to affect to the specified gradient
  59664. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59665. * @returns the current particle system
  59666. */
  59667. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59668. /**
  59669. * Not supported by GPUParticleSystem
  59670. * @param gradient defines the gradient to remove
  59671. * @returns the current particle system
  59672. */
  59673. removeEmitRateGradient(gradient: number): IParticleSystem;
  59674. /**
  59675. * Not supported by GPUParticleSystem
  59676. * @param gradient defines the gradient to use (between 0 and 1)
  59677. * @param factor defines the start size value to affect to the specified gradient
  59678. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59679. * @returns the current particle system
  59680. */
  59681. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59682. /**
  59683. * Not supported by GPUParticleSystem
  59684. * @param gradient defines the gradient to remove
  59685. * @returns the current particle system
  59686. */
  59687. removeStartSizeGradient(gradient: number): IParticleSystem;
  59688. /**
  59689. * Not supported by GPUParticleSystem
  59690. * @param gradient defines the gradient to use (between 0 and 1)
  59691. * @param min defines the color remap minimal range
  59692. * @param max defines the color remap maximal range
  59693. * @returns the current particle system
  59694. */
  59695. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  59696. /**
  59697. * Not supported by GPUParticleSystem
  59698. * @param gradient defines the gradient to remove
  59699. * @returns the current particle system
  59700. */
  59701. removeColorRemapGradient(): IParticleSystem;
  59702. /**
  59703. * Not supported by GPUParticleSystem
  59704. * @param gradient defines the gradient to use (between 0 and 1)
  59705. * @param min defines the alpha remap minimal range
  59706. * @param max defines the alpha remap maximal range
  59707. * @returns the current particle system
  59708. */
  59709. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  59710. /**
  59711. * Not supported by GPUParticleSystem
  59712. * @param gradient defines the gradient to remove
  59713. * @returns the current particle system
  59714. */
  59715. removeAlphaRemapGradient(): IParticleSystem;
  59716. /**
  59717. * Not supported by GPUParticleSystem
  59718. * @param gradient defines the gradient to use (between 0 and 1)
  59719. * @param color defines the color to affect to the specified gradient
  59720. * @returns the current particle system
  59721. */
  59722. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  59723. /**
  59724. * Not supported by GPUParticleSystem
  59725. * @param gradient defines the gradient to remove
  59726. * @returns the current particle system
  59727. */
  59728. removeRampGradient(): IParticleSystem;
  59729. /**
  59730. * Not supported by GPUParticleSystem
  59731. * @returns the list of ramp gradients
  59732. */
  59733. getRampGradients(): Nullable<Array<Color3Gradient>>;
  59734. /**
  59735. * Not supported by GPUParticleSystem
  59736. * Gets or sets a boolean indicating that ramp gradients must be used
  59737. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  59738. */
  59739. useRampGradients: boolean;
  59740. /**
  59741. * Not supported by GPUParticleSystem
  59742. * @param gradient defines the gradient to use (between 0 and 1)
  59743. * @param factor defines the life time factor to affect to the specified gradient
  59744. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59745. * @returns the current particle system
  59746. */
  59747. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59748. /**
  59749. * Not supported by GPUParticleSystem
  59750. * @param gradient defines the gradient to remove
  59751. * @returns the current particle system
  59752. */
  59753. removeLifeTimeGradient(gradient: number): IParticleSystem;
  59754. /**
  59755. * Instantiates a GPU particle system.
  59756. * 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.
  59757. * @param name The name of the particle system
  59758. * @param options The options used to create the system
  59759. * @param scene The scene the particle system belongs to
  59760. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  59761. */
  59762. constructor(name: string, options: Partial<{
  59763. capacity: number;
  59764. randomTextureSize: number;
  59765. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  59766. protected _reset(): void;
  59767. private _createUpdateVAO;
  59768. private _createRenderVAO;
  59769. private _initialize;
  59770. /** @hidden */
  59771. _recreateUpdateEffect(): void;
  59772. /** @hidden */
  59773. _recreateRenderEffect(): void;
  59774. /**
  59775. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  59776. * @param preWarm defines if we are in the pre-warmimg phase
  59777. */
  59778. animate(preWarm?: boolean): void;
  59779. private _createFactorGradientTexture;
  59780. private _createSizeGradientTexture;
  59781. private _createAngularSpeedGradientTexture;
  59782. private _createVelocityGradientTexture;
  59783. private _createLimitVelocityGradientTexture;
  59784. private _createDragGradientTexture;
  59785. private _createColorGradientTexture;
  59786. /**
  59787. * Renders the particle system in its current state
  59788. * @param preWarm defines if the system should only update the particles but not render them
  59789. * @returns the current number of particles
  59790. */
  59791. render(preWarm?: boolean): number;
  59792. /**
  59793. * Rebuilds the particle system
  59794. */
  59795. rebuild(): void;
  59796. private _releaseBuffers;
  59797. private _releaseVAOs;
  59798. /**
  59799. * Disposes the particle system and free the associated resources
  59800. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  59801. */
  59802. dispose(disposeTexture?: boolean): void;
  59803. /**
  59804. * Clones the particle system.
  59805. * @param name The name of the cloned object
  59806. * @param newEmitter The new emitter to use
  59807. * @returns the cloned particle system
  59808. */
  59809. clone(name: string, newEmitter: any): GPUParticleSystem;
  59810. /**
  59811. * Serializes the particle system to a JSON object.
  59812. * @returns the JSON object
  59813. */
  59814. serialize(): any;
  59815. /**
  59816. * Parses a JSON object to create a GPU particle system.
  59817. * @param parsedParticleSystem The JSON object to parse
  59818. * @param scene The scene to create the particle system in
  59819. * @param rootUrl The root url to use to load external dependencies like texture
  59820. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  59821. * @returns the parsed GPU particle system
  59822. */
  59823. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  59824. }
  59825. }
  59826. declare module BABYLON {
  59827. /**
  59828. * Represents a set of particle systems working together to create a specific effect
  59829. */
  59830. export class ParticleSystemSet implements IDisposable {
  59831. /**
  59832. * Gets or sets base Assets URL
  59833. */
  59834. static BaseAssetsUrl: string;
  59835. private _emitterCreationOptions;
  59836. private _emitterNode;
  59837. /**
  59838. * Gets the particle system list
  59839. */
  59840. systems: IParticleSystem[];
  59841. /**
  59842. * Gets the emitter node used with this set
  59843. */
  59844. readonly emitterNode: Nullable<TransformNode>;
  59845. /**
  59846. * Creates a new emitter mesh as a sphere
  59847. * @param options defines the options used to create the sphere
  59848. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  59849. * @param scene defines the hosting scene
  59850. */
  59851. setEmitterAsSphere(options: {
  59852. diameter: number;
  59853. segments: number;
  59854. color: Color3;
  59855. }, renderingGroupId: number, scene: Scene): void;
  59856. /**
  59857. * Starts all particle systems of the set
  59858. * @param emitter defines an optional mesh to use as emitter for the particle systems
  59859. */
  59860. start(emitter?: AbstractMesh): void;
  59861. /**
  59862. * Release all associated resources
  59863. */
  59864. dispose(): void;
  59865. /**
  59866. * Serialize the set into a JSON compatible object
  59867. * @returns a JSON compatible representation of the set
  59868. */
  59869. serialize(): any;
  59870. /**
  59871. * Parse a new ParticleSystemSet from a serialized source
  59872. * @param data defines a JSON compatible representation of the set
  59873. * @param scene defines the hosting scene
  59874. * @param gpu defines if we want GPU particles or CPU particles
  59875. * @returns a new ParticleSystemSet
  59876. */
  59877. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  59878. }
  59879. }
  59880. declare module BABYLON {
  59881. /**
  59882. * This class is made for on one-liner static method to help creating particle system set.
  59883. */
  59884. export class ParticleHelper {
  59885. /**
  59886. * Gets or sets base Assets URL
  59887. */
  59888. static BaseAssetsUrl: string;
  59889. /**
  59890. * Create a default particle system that you can tweak
  59891. * @param emitter defines the emitter to use
  59892. * @param capacity defines the system capacity (default is 500 particles)
  59893. * @param scene defines the hosting scene
  59894. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  59895. * @returns the new Particle system
  59896. */
  59897. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  59898. /**
  59899. * This is the main static method (one-liner) of this helper to create different particle systems
  59900. * @param type This string represents the type to the particle system to create
  59901. * @param scene The scene where the particle system should live
  59902. * @param gpu If the system will use gpu
  59903. * @returns the ParticleSystemSet created
  59904. */
  59905. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  59906. /**
  59907. * Static function used to export a particle system to a ParticleSystemSet variable.
  59908. * Please note that the emitter shape is not exported
  59909. * @param systems defines the particle systems to export
  59910. * @returns the created particle system set
  59911. */
  59912. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  59913. }
  59914. }
  59915. declare module BABYLON {
  59916. interface Engine {
  59917. /**
  59918. * Create an effect to use with particle systems.
  59919. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  59920. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  59921. * @param uniformsNames defines a list of attribute names
  59922. * @param samplers defines an array of string used to represent textures
  59923. * @param defines defines the string containing the defines to use to compile the shaders
  59924. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  59925. * @param onCompiled defines a function to call when the effect creation is successful
  59926. * @param onError defines a function to call when the effect creation has failed
  59927. * @returns the new Effect
  59928. */
  59929. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  59930. }
  59931. interface Mesh {
  59932. /**
  59933. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  59934. * @returns an array of IParticleSystem
  59935. */
  59936. getEmittedParticleSystems(): IParticleSystem[];
  59937. /**
  59938. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  59939. * @returns an array of IParticleSystem
  59940. */
  59941. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  59942. }
  59943. /**
  59944. * @hidden
  59945. */
  59946. export var _IDoNeedToBeInTheBuild: number;
  59947. }
  59948. declare module BABYLON {
  59949. /** Defines the 4 color options */
  59950. export enum PointColor {
  59951. /** color value */
  59952. Color = 2,
  59953. /** uv value */
  59954. UV = 1,
  59955. /** random value */
  59956. Random = 0,
  59957. /** stated value */
  59958. Stated = 3
  59959. }
  59960. /**
  59961. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  59962. * 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.
  59963. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  59964. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  59965. *
  59966. * Full documentation here : TO BE ENTERED
  59967. */
  59968. export class PointsCloudSystem implements IDisposable {
  59969. /**
  59970. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  59971. * Example : var p = SPS.particles[i];
  59972. */
  59973. particles: CloudPoint[];
  59974. /**
  59975. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  59976. */
  59977. nbParticles: number;
  59978. /**
  59979. * This a counter for your own usage. It's not set by any SPS functions.
  59980. */
  59981. counter: number;
  59982. /**
  59983. * The PCS name. This name is also given to the underlying mesh.
  59984. */
  59985. name: string;
  59986. /**
  59987. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  59988. */
  59989. mesh: Mesh;
  59990. /**
  59991. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  59992. * Please read :
  59993. */
  59994. vars: any;
  59995. /**
  59996. * @hidden
  59997. */
  59998. _size: number;
  59999. private _scene;
  60000. private _promises;
  60001. private _positions;
  60002. private _indices;
  60003. private _normals;
  60004. private _colors;
  60005. private _uvs;
  60006. private _indices32;
  60007. private _positions32;
  60008. private _colors32;
  60009. private _uvs32;
  60010. private _updatable;
  60011. private _isVisibilityBoxLocked;
  60012. private _alwaysVisible;
  60013. private _groups;
  60014. private _groupCounter;
  60015. private _computeParticleColor;
  60016. private _computeParticleTexture;
  60017. private _computeParticleRotation;
  60018. private _computeBoundingBox;
  60019. private _isReady;
  60020. /**
  60021. * Creates a PCS (Points Cloud System) object
  60022. * @param name (String) is the PCS name, this will be the underlying mesh name
  60023. * @param pointSize (number) is the size for each point
  60024. * @param scene (Scene) is the scene in which the PCS is added
  60025. * @param options defines the options of the PCS e.g.
  60026. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  60027. */
  60028. constructor(name: string, pointSize: number, scene: Scene, options?: {
  60029. updatable?: boolean;
  60030. });
  60031. /**
  60032. * Builds the PCS underlying mesh. Returns a standard Mesh.
  60033. * If no points were added to the PCS, the returned mesh is just a single point.
  60034. * @returns a promise for the created mesh
  60035. */
  60036. buildMeshAsync(): Promise<Mesh>;
  60037. /**
  60038. * @hidden
  60039. */
  60040. private _buildMesh;
  60041. private _addParticle;
  60042. private _randomUnitVector;
  60043. private _getColorIndicesForCoord;
  60044. private _setPointsColorOrUV;
  60045. private _colorFromTexture;
  60046. private _calculateDensity;
  60047. /**
  60048. * Adds points to the PCS in random positions within a unit sphere
  60049. * @param nb (positive integer) the number of particles to be created from this model
  60050. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  60051. * @returns the number of groups in the system
  60052. */
  60053. addPoints(nb: number, pointFunction?: any): number;
  60054. /**
  60055. * Adds points to the PCS from the surface of the model shape
  60056. * @param mesh is any Mesh object that will be used as a surface model for the points
  60057. * @param nb (positive integer) the number of particles to be created from this model
  60058. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  60059. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  60060. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  60061. * @returns the number of groups in the system
  60062. */
  60063. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  60064. /**
  60065. * Adds points to the PCS inside the model shape
  60066. * @param mesh is any Mesh object that will be used as a surface model for the points
  60067. * @param nb (positive integer) the number of particles to be created from this model
  60068. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  60069. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  60070. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  60071. * @returns the number of groups in the system
  60072. */
  60073. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  60074. /**
  60075. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  60076. * This method calls `updateParticle()` for each particle of the SPS.
  60077. * For an animated SPS, it is usually called within the render loop.
  60078. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  60079. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  60080. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  60081. * @returns the PCS.
  60082. */
  60083. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  60084. /**
  60085. * Disposes the PCS.
  60086. */
  60087. dispose(): void;
  60088. /**
  60089. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  60090. * doc :
  60091. * @returns the PCS.
  60092. */
  60093. refreshVisibleSize(): PointsCloudSystem;
  60094. /**
  60095. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  60096. * @param size the size (float) of the visibility box
  60097. * note : this doesn't lock the PCS mesh bounding box.
  60098. * doc :
  60099. */
  60100. setVisibilityBox(size: number): void;
  60101. /**
  60102. * Gets whether the PCS is always visible or not
  60103. * doc :
  60104. */
  60105. /**
  60106. * Sets the PCS as always visible or not
  60107. * doc :
  60108. */
  60109. isAlwaysVisible: boolean;
  60110. /**
  60111. * Tells to `setParticles()` to compute the particle rotations or not
  60112. * Default value : false. The PCS is faster when it's set to false
  60113. * Note : particle rotations are only applied to parent particles
  60114. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  60115. */
  60116. computeParticleRotation: boolean;
  60117. /**
  60118. * Tells to `setParticles()` to compute the particle colors or not.
  60119. * Default value : true. The PCS is faster when it's set to false.
  60120. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  60121. */
  60122. /**
  60123. * Gets if `setParticles()` computes the particle colors or not.
  60124. * Default value : false. The PCS is faster when it's set to false.
  60125. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  60126. */
  60127. computeParticleColor: boolean;
  60128. /**
  60129. * Gets if `setParticles()` computes the particle textures or not.
  60130. * Default value : false. The PCS is faster when it's set to false.
  60131. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  60132. */
  60133. computeParticleTexture: boolean;
  60134. /**
  60135. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  60136. */
  60137. /**
  60138. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  60139. */
  60140. computeBoundingBox: boolean;
  60141. /**
  60142. * This function does nothing. It may be overwritten to set all the particle first values.
  60143. * The PCS doesn't call this function, you may have to call it by your own.
  60144. * doc :
  60145. */
  60146. initParticles(): void;
  60147. /**
  60148. * This function does nothing. It may be overwritten to recycle a particle
  60149. * The PCS doesn't call this function, you can to call it
  60150. * doc :
  60151. * @param particle The particle to recycle
  60152. * @returns the recycled particle
  60153. */
  60154. recycleParticle(particle: CloudPoint): CloudPoint;
  60155. /**
  60156. * Updates a particle : this function should be overwritten by the user.
  60157. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  60158. * doc :
  60159. * @example : just set a particle position or velocity and recycle conditions
  60160. * @param particle The particle to update
  60161. * @returns the updated particle
  60162. */
  60163. updateParticle(particle: CloudPoint): CloudPoint;
  60164. /**
  60165. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  60166. * This does nothing and may be overwritten by the user.
  60167. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  60168. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  60169. * @param update the boolean update value actually passed to setParticles()
  60170. */
  60171. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  60172. /**
  60173. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  60174. * This will be passed three parameters.
  60175. * This does nothing and may be overwritten by the user.
  60176. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  60177. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  60178. * @param update the boolean update value actually passed to setParticles()
  60179. */
  60180. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  60181. }
  60182. }
  60183. declare module BABYLON {
  60184. /**
  60185. * Represents one particle of a points cloud system.
  60186. */
  60187. export class CloudPoint {
  60188. /**
  60189. * particle global index
  60190. */
  60191. idx: number;
  60192. /**
  60193. * The color of the particle
  60194. */
  60195. color: Nullable<Color4>;
  60196. /**
  60197. * The world space position of the particle.
  60198. */
  60199. position: Vector3;
  60200. /**
  60201. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  60202. */
  60203. rotation: Vector3;
  60204. /**
  60205. * The world space rotation quaternion of the particle.
  60206. */
  60207. rotationQuaternion: Nullable<Quaternion>;
  60208. /**
  60209. * The uv of the particle.
  60210. */
  60211. uv: Nullable<Vector2>;
  60212. /**
  60213. * The current speed of the particle.
  60214. */
  60215. velocity: Vector3;
  60216. /**
  60217. * The pivot point in the particle local space.
  60218. */
  60219. pivot: Vector3;
  60220. /**
  60221. * Must the particle be translated from its pivot point in its local space ?
  60222. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  60223. * Default : false
  60224. */
  60225. translateFromPivot: boolean;
  60226. /**
  60227. * Index of this particle in the global "positions" array (Internal use)
  60228. * @hidden
  60229. */
  60230. _pos: number;
  60231. /**
  60232. * @hidden Index of this particle in the global "indices" array (Internal use)
  60233. */
  60234. _ind: number;
  60235. /**
  60236. * Group this particle belongs to
  60237. */
  60238. _group: PointsGroup;
  60239. /**
  60240. * Group id of this particle
  60241. */
  60242. groupId: number;
  60243. /**
  60244. * Index of the particle in its group id (Internal use)
  60245. */
  60246. idxInGroup: number;
  60247. /**
  60248. * @hidden Particle BoundingInfo object (Internal use)
  60249. */
  60250. _boundingInfo: BoundingInfo;
  60251. /**
  60252. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  60253. */
  60254. _pcs: PointsCloudSystem;
  60255. /**
  60256. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  60257. */
  60258. _stillInvisible: boolean;
  60259. /**
  60260. * @hidden Last computed particle rotation matrix
  60261. */
  60262. _rotationMatrix: number[];
  60263. /**
  60264. * Parent particle Id, if any.
  60265. * Default null.
  60266. */
  60267. parentId: Nullable<number>;
  60268. /**
  60269. * @hidden Internal global position in the PCS.
  60270. */
  60271. _globalPosition: Vector3;
  60272. /**
  60273. * Creates a Point Cloud object.
  60274. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  60275. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  60276. * @param group (PointsGroup) is the group the particle belongs to
  60277. * @param groupId (integer) is the group identifier in the PCS.
  60278. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  60279. * @param pcs defines the PCS it is associated to
  60280. */
  60281. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  60282. /**
  60283. * get point size
  60284. */
  60285. /**
  60286. * Set point size
  60287. */
  60288. size: Vector3;
  60289. /**
  60290. * Legacy support, changed quaternion to rotationQuaternion
  60291. */
  60292. /**
  60293. * Legacy support, changed quaternion to rotationQuaternion
  60294. */
  60295. quaternion: Nullable<Quaternion>;
  60296. /**
  60297. * Returns a boolean. True if the particle intersects a mesh, else false
  60298. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  60299. * @param target is the object (point or mesh) what the intersection is computed against
  60300. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  60301. * @returns true if it intersects
  60302. */
  60303. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  60304. /**
  60305. * get the rotation matrix of the particle
  60306. * @hidden
  60307. */
  60308. getRotationMatrix(m: Matrix): void;
  60309. }
  60310. /**
  60311. * Represents a group of points in a points cloud system
  60312. * * PCS internal tool, don't use it manually.
  60313. */
  60314. export class PointsGroup {
  60315. /**
  60316. * The group id
  60317. * @hidden
  60318. */
  60319. groupID: number;
  60320. /**
  60321. * image data for group (internal use)
  60322. * @hidden
  60323. */
  60324. _groupImageData: Nullable<ArrayBufferView>;
  60325. /**
  60326. * Image Width (internal use)
  60327. * @hidden
  60328. */
  60329. _groupImgWidth: number;
  60330. /**
  60331. * Image Height (internal use)
  60332. * @hidden
  60333. */
  60334. _groupImgHeight: number;
  60335. /**
  60336. * Custom position function (internal use)
  60337. * @hidden
  60338. */
  60339. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  60340. /**
  60341. * density per facet for surface points
  60342. * @hidden
  60343. */
  60344. _groupDensity: number[];
  60345. /**
  60346. * Only when points are colored by texture carries pointer to texture list array
  60347. * @hidden
  60348. */
  60349. _textureNb: number;
  60350. /**
  60351. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  60352. * PCS internal tool, don't use it manually.
  60353. * @hidden
  60354. */
  60355. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  60356. }
  60357. }
  60358. declare module BABYLON {
  60359. interface Scene {
  60360. /** @hidden (Backing field) */
  60361. _physicsEngine: Nullable<IPhysicsEngine>;
  60362. /** @hidden */
  60363. _physicsTimeAccumulator: number;
  60364. /**
  60365. * Gets the current physics engine
  60366. * @returns a IPhysicsEngine or null if none attached
  60367. */
  60368. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  60369. /**
  60370. * Enables physics to the current scene
  60371. * @param gravity defines the scene's gravity for the physics engine
  60372. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  60373. * @return a boolean indicating if the physics engine was initialized
  60374. */
  60375. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  60376. /**
  60377. * Disables and disposes the physics engine associated with the scene
  60378. */
  60379. disablePhysicsEngine(): void;
  60380. /**
  60381. * Gets a boolean indicating if there is an active physics engine
  60382. * @returns a boolean indicating if there is an active physics engine
  60383. */
  60384. isPhysicsEnabled(): boolean;
  60385. /**
  60386. * Deletes a physics compound impostor
  60387. * @param compound defines the compound to delete
  60388. */
  60389. deleteCompoundImpostor(compound: any): void;
  60390. /**
  60391. * An event triggered when physic simulation is about to be run
  60392. */
  60393. onBeforePhysicsObservable: Observable<Scene>;
  60394. /**
  60395. * An event triggered when physic simulation has been done
  60396. */
  60397. onAfterPhysicsObservable: Observable<Scene>;
  60398. }
  60399. interface AbstractMesh {
  60400. /** @hidden */
  60401. _physicsImpostor: Nullable<PhysicsImpostor>;
  60402. /**
  60403. * Gets or sets impostor used for physic simulation
  60404. * @see http://doc.babylonjs.com/features/physics_engine
  60405. */
  60406. physicsImpostor: Nullable<PhysicsImpostor>;
  60407. /**
  60408. * Gets the current physics impostor
  60409. * @see http://doc.babylonjs.com/features/physics_engine
  60410. * @returns a physics impostor or null
  60411. */
  60412. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  60413. /** Apply a physic impulse to the mesh
  60414. * @param force defines the force to apply
  60415. * @param contactPoint defines where to apply the force
  60416. * @returns the current mesh
  60417. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  60418. */
  60419. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  60420. /**
  60421. * Creates a physic joint between two meshes
  60422. * @param otherMesh defines the other mesh to use
  60423. * @param pivot1 defines the pivot to use on this mesh
  60424. * @param pivot2 defines the pivot to use on the other mesh
  60425. * @param options defines additional options (can be plugin dependent)
  60426. * @returns the current mesh
  60427. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  60428. */
  60429. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  60430. /** @hidden */
  60431. _disposePhysicsObserver: Nullable<Observer<Node>>;
  60432. }
  60433. /**
  60434. * Defines the physics engine scene component responsible to manage a physics engine
  60435. */
  60436. export class PhysicsEngineSceneComponent implements ISceneComponent {
  60437. /**
  60438. * The component name helpful to identify the component in the list of scene components.
  60439. */
  60440. readonly name: string;
  60441. /**
  60442. * The scene the component belongs to.
  60443. */
  60444. scene: Scene;
  60445. /**
  60446. * Creates a new instance of the component for the given scene
  60447. * @param scene Defines the scene to register the component in
  60448. */
  60449. constructor(scene: Scene);
  60450. /**
  60451. * Registers the component in a given scene
  60452. */
  60453. register(): void;
  60454. /**
  60455. * Rebuilds the elements related to this component in case of
  60456. * context lost for instance.
  60457. */
  60458. rebuild(): void;
  60459. /**
  60460. * Disposes the component and the associated ressources
  60461. */
  60462. dispose(): void;
  60463. }
  60464. }
  60465. declare module BABYLON {
  60466. /**
  60467. * A helper for physics simulations
  60468. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60469. */
  60470. export class PhysicsHelper {
  60471. private _scene;
  60472. private _physicsEngine;
  60473. /**
  60474. * Initializes the Physics helper
  60475. * @param scene Babylon.js scene
  60476. */
  60477. constructor(scene: Scene);
  60478. /**
  60479. * Applies a radial explosion impulse
  60480. * @param origin the origin of the explosion
  60481. * @param radiusOrEventOptions the radius or the options of radial explosion
  60482. * @param strength the explosion strength
  60483. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60484. * @returns A physics radial explosion event, or null
  60485. */
  60486. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60487. /**
  60488. * Applies a radial explosion force
  60489. * @param origin the origin of the explosion
  60490. * @param radiusOrEventOptions the radius or the options of radial explosion
  60491. * @param strength the explosion strength
  60492. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60493. * @returns A physics radial explosion event, or null
  60494. */
  60495. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60496. /**
  60497. * Creates a gravitational field
  60498. * @param origin the origin of the explosion
  60499. * @param radiusOrEventOptions the radius or the options of radial explosion
  60500. * @param strength the explosion strength
  60501. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60502. * @returns A physics gravitational field event, or null
  60503. */
  60504. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  60505. /**
  60506. * Creates a physics updraft event
  60507. * @param origin the origin of the updraft
  60508. * @param radiusOrEventOptions the radius or the options of the updraft
  60509. * @param strength the strength of the updraft
  60510. * @param height the height of the updraft
  60511. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  60512. * @returns A physics updraft event, or null
  60513. */
  60514. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  60515. /**
  60516. * Creates a physics vortex event
  60517. * @param origin the of the vortex
  60518. * @param radiusOrEventOptions the radius or the options of the vortex
  60519. * @param strength the strength of the vortex
  60520. * @param height the height of the vortex
  60521. * @returns a Physics vortex event, or null
  60522. * A physics vortex event or null
  60523. */
  60524. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  60525. }
  60526. /**
  60527. * Represents a physics radial explosion event
  60528. */
  60529. class PhysicsRadialExplosionEvent {
  60530. private _scene;
  60531. private _options;
  60532. private _sphere;
  60533. private _dataFetched;
  60534. /**
  60535. * Initializes a radial explosioin event
  60536. * @param _scene BabylonJS scene
  60537. * @param _options The options for the vortex event
  60538. */
  60539. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  60540. /**
  60541. * Returns the data related to the radial explosion event (sphere).
  60542. * @returns The radial explosion event data
  60543. */
  60544. getData(): PhysicsRadialExplosionEventData;
  60545. /**
  60546. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  60547. * @param impostor A physics imposter
  60548. * @param origin the origin of the explosion
  60549. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  60550. */
  60551. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  60552. /**
  60553. * Triggers affecterd impostors callbacks
  60554. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  60555. */
  60556. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  60557. /**
  60558. * Disposes the sphere.
  60559. * @param force Specifies if the sphere should be disposed by force
  60560. */
  60561. dispose(force?: boolean): void;
  60562. /*** Helpers ***/
  60563. private _prepareSphere;
  60564. private _intersectsWithSphere;
  60565. }
  60566. /**
  60567. * Represents a gravitational field event
  60568. */
  60569. class PhysicsGravitationalFieldEvent {
  60570. private _physicsHelper;
  60571. private _scene;
  60572. private _origin;
  60573. private _options;
  60574. private _tickCallback;
  60575. private _sphere;
  60576. private _dataFetched;
  60577. /**
  60578. * Initializes the physics gravitational field event
  60579. * @param _physicsHelper A physics helper
  60580. * @param _scene BabylonJS scene
  60581. * @param _origin The origin position of the gravitational field event
  60582. * @param _options The options for the vortex event
  60583. */
  60584. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  60585. /**
  60586. * Returns the data related to the gravitational field event (sphere).
  60587. * @returns A gravitational field event
  60588. */
  60589. getData(): PhysicsGravitationalFieldEventData;
  60590. /**
  60591. * Enables the gravitational field.
  60592. */
  60593. enable(): void;
  60594. /**
  60595. * Disables the gravitational field.
  60596. */
  60597. disable(): void;
  60598. /**
  60599. * Disposes the sphere.
  60600. * @param force The force to dispose from the gravitational field event
  60601. */
  60602. dispose(force?: boolean): void;
  60603. private _tick;
  60604. }
  60605. /**
  60606. * Represents a physics updraft event
  60607. */
  60608. class PhysicsUpdraftEvent {
  60609. private _scene;
  60610. private _origin;
  60611. private _options;
  60612. private _physicsEngine;
  60613. private _originTop;
  60614. private _originDirection;
  60615. private _tickCallback;
  60616. private _cylinder;
  60617. private _cylinderPosition;
  60618. private _dataFetched;
  60619. /**
  60620. * Initializes the physics updraft event
  60621. * @param _scene BabylonJS scene
  60622. * @param _origin The origin position of the updraft
  60623. * @param _options The options for the updraft event
  60624. */
  60625. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  60626. /**
  60627. * Returns the data related to the updraft event (cylinder).
  60628. * @returns A physics updraft event
  60629. */
  60630. getData(): PhysicsUpdraftEventData;
  60631. /**
  60632. * Enables the updraft.
  60633. */
  60634. enable(): void;
  60635. /**
  60636. * Disables the updraft.
  60637. */
  60638. disable(): void;
  60639. /**
  60640. * Disposes the cylinder.
  60641. * @param force Specifies if the updraft should be disposed by force
  60642. */
  60643. dispose(force?: boolean): void;
  60644. private getImpostorHitData;
  60645. private _tick;
  60646. /*** Helpers ***/
  60647. private _prepareCylinder;
  60648. private _intersectsWithCylinder;
  60649. }
  60650. /**
  60651. * Represents a physics vortex event
  60652. */
  60653. class PhysicsVortexEvent {
  60654. private _scene;
  60655. private _origin;
  60656. private _options;
  60657. private _physicsEngine;
  60658. private _originTop;
  60659. private _tickCallback;
  60660. private _cylinder;
  60661. private _cylinderPosition;
  60662. private _dataFetched;
  60663. /**
  60664. * Initializes the physics vortex event
  60665. * @param _scene The BabylonJS scene
  60666. * @param _origin The origin position of the vortex
  60667. * @param _options The options for the vortex event
  60668. */
  60669. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  60670. /**
  60671. * Returns the data related to the vortex event (cylinder).
  60672. * @returns The physics vortex event data
  60673. */
  60674. getData(): PhysicsVortexEventData;
  60675. /**
  60676. * Enables the vortex.
  60677. */
  60678. enable(): void;
  60679. /**
  60680. * Disables the cortex.
  60681. */
  60682. disable(): void;
  60683. /**
  60684. * Disposes the sphere.
  60685. * @param force
  60686. */
  60687. dispose(force?: boolean): void;
  60688. private getImpostorHitData;
  60689. private _tick;
  60690. /*** Helpers ***/
  60691. private _prepareCylinder;
  60692. private _intersectsWithCylinder;
  60693. }
  60694. /**
  60695. * Options fot the radial explosion event
  60696. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60697. */
  60698. export class PhysicsRadialExplosionEventOptions {
  60699. /**
  60700. * The radius of the sphere for the radial explosion.
  60701. */
  60702. radius: number;
  60703. /**
  60704. * The strenth of the explosion.
  60705. */
  60706. strength: number;
  60707. /**
  60708. * The strenght of the force in correspondence to the distance of the affected object
  60709. */
  60710. falloff: PhysicsRadialImpulseFalloff;
  60711. /**
  60712. * Sphere options for the radial explosion.
  60713. */
  60714. sphere: {
  60715. segments: number;
  60716. diameter: number;
  60717. };
  60718. /**
  60719. * Sphere options for the radial explosion.
  60720. */
  60721. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  60722. }
  60723. /**
  60724. * Options fot the updraft event
  60725. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60726. */
  60727. export class PhysicsUpdraftEventOptions {
  60728. /**
  60729. * The radius of the cylinder for the vortex
  60730. */
  60731. radius: number;
  60732. /**
  60733. * The strenth of the updraft.
  60734. */
  60735. strength: number;
  60736. /**
  60737. * The height of the cylinder for the updraft.
  60738. */
  60739. height: number;
  60740. /**
  60741. * The mode for the the updraft.
  60742. */
  60743. updraftMode: PhysicsUpdraftMode;
  60744. }
  60745. /**
  60746. * Options fot the vortex event
  60747. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60748. */
  60749. export class PhysicsVortexEventOptions {
  60750. /**
  60751. * The radius of the cylinder for the vortex
  60752. */
  60753. radius: number;
  60754. /**
  60755. * The strenth of the vortex.
  60756. */
  60757. strength: number;
  60758. /**
  60759. * The height of the cylinder for the vortex.
  60760. */
  60761. height: number;
  60762. /**
  60763. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  60764. */
  60765. centripetalForceThreshold: number;
  60766. /**
  60767. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  60768. */
  60769. centripetalForceMultiplier: number;
  60770. /**
  60771. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  60772. */
  60773. centrifugalForceMultiplier: number;
  60774. /**
  60775. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  60776. */
  60777. updraftForceMultiplier: number;
  60778. }
  60779. /**
  60780. * The strenght of the force in correspondence to the distance of the affected object
  60781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60782. */
  60783. export enum PhysicsRadialImpulseFalloff {
  60784. /** Defines that impulse is constant in strength across it's whole radius */
  60785. Constant = 0,
  60786. /** Defines that impulse gets weaker if it's further from the origin */
  60787. Linear = 1
  60788. }
  60789. /**
  60790. * The strength of the force in correspondence to the distance of the affected object
  60791. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60792. */
  60793. export enum PhysicsUpdraftMode {
  60794. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  60795. Center = 0,
  60796. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  60797. Perpendicular = 1
  60798. }
  60799. /**
  60800. * Interface for a physics hit data
  60801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60802. */
  60803. export interface PhysicsHitData {
  60804. /**
  60805. * The force applied at the contact point
  60806. */
  60807. force: Vector3;
  60808. /**
  60809. * The contact point
  60810. */
  60811. contactPoint: Vector3;
  60812. /**
  60813. * The distance from the origin to the contact point
  60814. */
  60815. distanceFromOrigin: number;
  60816. }
  60817. /**
  60818. * Interface for radial explosion event data
  60819. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60820. */
  60821. export interface PhysicsRadialExplosionEventData {
  60822. /**
  60823. * A sphere used for the radial explosion event
  60824. */
  60825. sphere: Mesh;
  60826. }
  60827. /**
  60828. * Interface for gravitational field event data
  60829. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60830. */
  60831. export interface PhysicsGravitationalFieldEventData {
  60832. /**
  60833. * A sphere mesh used for the gravitational field event
  60834. */
  60835. sphere: Mesh;
  60836. }
  60837. /**
  60838. * Interface for updraft event data
  60839. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60840. */
  60841. export interface PhysicsUpdraftEventData {
  60842. /**
  60843. * A cylinder used for the updraft event
  60844. */
  60845. cylinder: Mesh;
  60846. }
  60847. /**
  60848. * Interface for vortex event data
  60849. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60850. */
  60851. export interface PhysicsVortexEventData {
  60852. /**
  60853. * A cylinder used for the vortex event
  60854. */
  60855. cylinder: Mesh;
  60856. }
  60857. /**
  60858. * Interface for an affected physics impostor
  60859. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60860. */
  60861. export interface PhysicsAffectedImpostorWithData {
  60862. /**
  60863. * The impostor affected by the effect
  60864. */
  60865. impostor: PhysicsImpostor;
  60866. /**
  60867. * The data about the hit/horce from the explosion
  60868. */
  60869. hitData: PhysicsHitData;
  60870. }
  60871. }
  60872. declare module BABYLON {
  60873. /** @hidden */
  60874. export var blackAndWhitePixelShader: {
  60875. name: string;
  60876. shader: string;
  60877. };
  60878. }
  60879. declare module BABYLON {
  60880. /**
  60881. * Post process used to render in black and white
  60882. */
  60883. export class BlackAndWhitePostProcess extends PostProcess {
  60884. /**
  60885. * Linear about to convert he result to black and white (default: 1)
  60886. */
  60887. degree: number;
  60888. /**
  60889. * Creates a black and white post process
  60890. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  60891. * @param name The name of the effect.
  60892. * @param options The required width/height ratio to downsize to before computing the render pass.
  60893. * @param camera The camera to apply the render pass to.
  60894. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60895. * @param engine The engine which the post process will be applied. (default: current engine)
  60896. * @param reusable If the post process can be reused on the same frame. (default: false)
  60897. */
  60898. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60899. }
  60900. }
  60901. declare module BABYLON {
  60902. /**
  60903. * This represents a set of one or more post processes in Babylon.
  60904. * A post process can be used to apply a shader to a texture after it is rendered.
  60905. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60906. */
  60907. export class PostProcessRenderEffect {
  60908. private _postProcesses;
  60909. private _getPostProcesses;
  60910. private _singleInstance;
  60911. private _cameras;
  60912. private _indicesForCamera;
  60913. /**
  60914. * Name of the effect
  60915. * @hidden
  60916. */
  60917. _name: string;
  60918. /**
  60919. * Instantiates a post process render effect.
  60920. * A post process can be used to apply a shader to a texture after it is rendered.
  60921. * @param engine The engine the effect is tied to
  60922. * @param name The name of the effect
  60923. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  60924. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  60925. */
  60926. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  60927. /**
  60928. * Checks if all the post processes in the effect are supported.
  60929. */
  60930. readonly isSupported: boolean;
  60931. /**
  60932. * Updates the current state of the effect
  60933. * @hidden
  60934. */
  60935. _update(): void;
  60936. /**
  60937. * Attaches the effect on cameras
  60938. * @param cameras The camera to attach to.
  60939. * @hidden
  60940. */
  60941. _attachCameras(cameras: Camera): void;
  60942. /**
  60943. * Attaches the effect on cameras
  60944. * @param cameras The camera to attach to.
  60945. * @hidden
  60946. */
  60947. _attachCameras(cameras: Camera[]): void;
  60948. /**
  60949. * Detaches the effect on cameras
  60950. * @param cameras The camera to detatch from.
  60951. * @hidden
  60952. */
  60953. _detachCameras(cameras: Camera): void;
  60954. /**
  60955. * Detatches the effect on cameras
  60956. * @param cameras The camera to detatch from.
  60957. * @hidden
  60958. */
  60959. _detachCameras(cameras: Camera[]): void;
  60960. /**
  60961. * Enables the effect on given cameras
  60962. * @param cameras The camera to enable.
  60963. * @hidden
  60964. */
  60965. _enable(cameras: Camera): void;
  60966. /**
  60967. * Enables the effect on given cameras
  60968. * @param cameras The camera to enable.
  60969. * @hidden
  60970. */
  60971. _enable(cameras: Nullable<Camera[]>): void;
  60972. /**
  60973. * Disables the effect on the given cameras
  60974. * @param cameras The camera to disable.
  60975. * @hidden
  60976. */
  60977. _disable(cameras: Camera): void;
  60978. /**
  60979. * Disables the effect on the given cameras
  60980. * @param cameras The camera to disable.
  60981. * @hidden
  60982. */
  60983. _disable(cameras: Nullable<Camera[]>): void;
  60984. /**
  60985. * Gets a list of the post processes contained in the effect.
  60986. * @param camera The camera to get the post processes on.
  60987. * @returns The list of the post processes in the effect.
  60988. */
  60989. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  60990. }
  60991. }
  60992. declare module BABYLON {
  60993. /** @hidden */
  60994. export var extractHighlightsPixelShader: {
  60995. name: string;
  60996. shader: string;
  60997. };
  60998. }
  60999. declare module BABYLON {
  61000. /**
  61001. * 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.
  61002. */
  61003. export class ExtractHighlightsPostProcess extends PostProcess {
  61004. /**
  61005. * The luminance threshold, pixels below this value will be set to black.
  61006. */
  61007. threshold: number;
  61008. /** @hidden */
  61009. _exposure: number;
  61010. /**
  61011. * Post process which has the input texture to be used when performing highlight extraction
  61012. * @hidden
  61013. */
  61014. _inputPostProcess: Nullable<PostProcess>;
  61015. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61016. }
  61017. }
  61018. declare module BABYLON {
  61019. /** @hidden */
  61020. export var bloomMergePixelShader: {
  61021. name: string;
  61022. shader: string;
  61023. };
  61024. }
  61025. declare module BABYLON {
  61026. /**
  61027. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61028. */
  61029. export class BloomMergePostProcess extends PostProcess {
  61030. /** Weight of the bloom to be added to the original input. */
  61031. weight: number;
  61032. /**
  61033. * Creates a new instance of @see BloomMergePostProcess
  61034. * @param name The name of the effect.
  61035. * @param originalFromInput Post process which's input will be used for the merge.
  61036. * @param blurred Blurred highlights post process which's output will be used.
  61037. * @param weight Weight of the bloom to be added to the original input.
  61038. * @param options The required width/height ratio to downsize to before computing the render pass.
  61039. * @param camera The camera to apply the render pass to.
  61040. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61041. * @param engine The engine which the post process will be applied. (default: current engine)
  61042. * @param reusable If the post process can be reused on the same frame. (default: false)
  61043. * @param textureType Type of textures used when performing the post process. (default: 0)
  61044. * @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)
  61045. */
  61046. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  61047. /** Weight of the bloom to be added to the original input. */
  61048. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61049. }
  61050. }
  61051. declare module BABYLON {
  61052. /**
  61053. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  61054. */
  61055. export class BloomEffect extends PostProcessRenderEffect {
  61056. private bloomScale;
  61057. /**
  61058. * @hidden Internal
  61059. */
  61060. _effects: Array<PostProcess>;
  61061. /**
  61062. * @hidden Internal
  61063. */
  61064. _downscale: ExtractHighlightsPostProcess;
  61065. private _blurX;
  61066. private _blurY;
  61067. private _merge;
  61068. /**
  61069. * The luminance threshold to find bright areas of the image to bloom.
  61070. */
  61071. threshold: number;
  61072. /**
  61073. * The strength of the bloom.
  61074. */
  61075. weight: number;
  61076. /**
  61077. * Specifies the size of the bloom blur kernel, relative to the final output size
  61078. */
  61079. kernel: number;
  61080. /**
  61081. * Creates a new instance of @see BloomEffect
  61082. * @param scene The scene the effect belongs to.
  61083. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  61084. * @param bloomKernel The size of the kernel to be used when applying the blur.
  61085. * @param bloomWeight The the strength of bloom.
  61086. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61087. * @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)
  61088. */
  61089. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  61090. /**
  61091. * Disposes each of the internal effects for a given camera.
  61092. * @param camera The camera to dispose the effect on.
  61093. */
  61094. disposeEffects(camera: Camera): void;
  61095. /**
  61096. * @hidden Internal
  61097. */
  61098. _updateEffects(): void;
  61099. /**
  61100. * Internal
  61101. * @returns if all the contained post processes are ready.
  61102. * @hidden
  61103. */
  61104. _isReady(): boolean;
  61105. }
  61106. }
  61107. declare module BABYLON {
  61108. /** @hidden */
  61109. export var chromaticAberrationPixelShader: {
  61110. name: string;
  61111. shader: string;
  61112. };
  61113. }
  61114. declare module BABYLON {
  61115. /**
  61116. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  61117. */
  61118. export class ChromaticAberrationPostProcess extends PostProcess {
  61119. /**
  61120. * The amount of seperation of rgb channels (default: 30)
  61121. */
  61122. aberrationAmount: number;
  61123. /**
  61124. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  61125. */
  61126. radialIntensity: number;
  61127. /**
  61128. * 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))
  61129. */
  61130. direction: Vector2;
  61131. /**
  61132. * 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))
  61133. */
  61134. centerPosition: Vector2;
  61135. /**
  61136. * Creates a new instance ChromaticAberrationPostProcess
  61137. * @param name The name of the effect.
  61138. * @param screenWidth The width of the screen to apply the effect on.
  61139. * @param screenHeight The height of the screen to apply the effect on.
  61140. * @param options The required width/height ratio to downsize to before computing the render pass.
  61141. * @param camera The camera to apply the render pass to.
  61142. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61143. * @param engine The engine which the post process will be applied. (default: current engine)
  61144. * @param reusable If the post process can be reused on the same frame. (default: false)
  61145. * @param textureType Type of textures used when performing the post process. (default: 0)
  61146. * @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)
  61147. */
  61148. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61149. }
  61150. }
  61151. declare module BABYLON {
  61152. /** @hidden */
  61153. export var circleOfConfusionPixelShader: {
  61154. name: string;
  61155. shader: string;
  61156. };
  61157. }
  61158. declare module BABYLON {
  61159. /**
  61160. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  61161. */
  61162. export class CircleOfConfusionPostProcess extends PostProcess {
  61163. /**
  61164. * 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.
  61165. */
  61166. lensSize: number;
  61167. /**
  61168. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61169. */
  61170. fStop: number;
  61171. /**
  61172. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61173. */
  61174. focusDistance: number;
  61175. /**
  61176. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  61177. */
  61178. focalLength: number;
  61179. private _depthTexture;
  61180. /**
  61181. * Creates a new instance CircleOfConfusionPostProcess
  61182. * @param name The name of the effect.
  61183. * @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.
  61184. * @param options The required width/height ratio to downsize to before computing the render pass.
  61185. * @param camera The camera to apply the render pass to.
  61186. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61187. * @param engine The engine which the post process will be applied. (default: current engine)
  61188. * @param reusable If the post process can be reused on the same frame. (default: false)
  61189. * @param textureType Type of textures used when performing the post process. (default: 0)
  61190. * @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)
  61191. */
  61192. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61193. /**
  61194. * 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.
  61195. */
  61196. depthTexture: RenderTargetTexture;
  61197. }
  61198. }
  61199. declare module BABYLON {
  61200. /** @hidden */
  61201. export var colorCorrectionPixelShader: {
  61202. name: string;
  61203. shader: string;
  61204. };
  61205. }
  61206. declare module BABYLON {
  61207. /**
  61208. *
  61209. * This post-process allows the modification of rendered colors by using
  61210. * a 'look-up table' (LUT). This effect is also called Color Grading.
  61211. *
  61212. * The object needs to be provided an url to a texture containing the color
  61213. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  61214. * Use an image editing software to tweak the LUT to match your needs.
  61215. *
  61216. * For an example of a color LUT, see here:
  61217. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  61218. * For explanations on color grading, see here:
  61219. * @see http://udn.epicgames.com/Three/ColorGrading.html
  61220. *
  61221. */
  61222. export class ColorCorrectionPostProcess extends PostProcess {
  61223. private _colorTableTexture;
  61224. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61225. }
  61226. }
  61227. declare module BABYLON {
  61228. /** @hidden */
  61229. export var convolutionPixelShader: {
  61230. name: string;
  61231. shader: string;
  61232. };
  61233. }
  61234. declare module BABYLON {
  61235. /**
  61236. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  61237. * input texture to perform effects such as edge detection or sharpening
  61238. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61239. */
  61240. export class ConvolutionPostProcess extends PostProcess {
  61241. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61242. kernel: number[];
  61243. /**
  61244. * Creates a new instance ConvolutionPostProcess
  61245. * @param name The name of the effect.
  61246. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  61247. * @param options The required width/height ratio to downsize to before computing the render pass.
  61248. * @param camera The camera to apply the render pass to.
  61249. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61250. * @param engine The engine which the post process will be applied. (default: current engine)
  61251. * @param reusable If the post process can be reused on the same frame. (default: false)
  61252. * @param textureType Type of textures used when performing the post process. (default: 0)
  61253. */
  61254. constructor(name: string,
  61255. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61256. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61257. /**
  61258. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61259. */
  61260. static EdgeDetect0Kernel: number[];
  61261. /**
  61262. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61263. */
  61264. static EdgeDetect1Kernel: number[];
  61265. /**
  61266. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61267. */
  61268. static EdgeDetect2Kernel: number[];
  61269. /**
  61270. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61271. */
  61272. static SharpenKernel: number[];
  61273. /**
  61274. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61275. */
  61276. static EmbossKernel: number[];
  61277. /**
  61278. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61279. */
  61280. static GaussianKernel: number[];
  61281. }
  61282. }
  61283. declare module BABYLON {
  61284. /**
  61285. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  61286. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  61287. * based on samples that have a large difference in distance than the center pixel.
  61288. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  61289. */
  61290. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  61291. direction: Vector2;
  61292. /**
  61293. * Creates a new instance CircleOfConfusionPostProcess
  61294. * @param name The name of the effect.
  61295. * @param scene The scene the effect belongs to.
  61296. * @param direction The direction the blur should be applied.
  61297. * @param kernel The size of the kernel used to blur.
  61298. * @param options The required width/height ratio to downsize to before computing the render pass.
  61299. * @param camera The camera to apply the render pass to.
  61300. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  61301. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  61302. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61303. * @param engine The engine which the post process will be applied. (default: current engine)
  61304. * @param reusable If the post process can be reused on the same frame. (default: false)
  61305. * @param textureType Type of textures used when performing the post process. (default: 0)
  61306. * @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)
  61307. */
  61308. 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);
  61309. }
  61310. }
  61311. declare module BABYLON {
  61312. /** @hidden */
  61313. export var depthOfFieldMergePixelShader: {
  61314. name: string;
  61315. shader: string;
  61316. };
  61317. }
  61318. declare module BABYLON {
  61319. /**
  61320. * Options to be set when merging outputs from the default pipeline.
  61321. */
  61322. export class DepthOfFieldMergePostProcessOptions {
  61323. /**
  61324. * The original image to merge on top of
  61325. */
  61326. originalFromInput: PostProcess;
  61327. /**
  61328. * Parameters to perform the merge of the depth of field effect
  61329. */
  61330. depthOfField?: {
  61331. circleOfConfusion: PostProcess;
  61332. blurSteps: Array<PostProcess>;
  61333. };
  61334. /**
  61335. * Parameters to perform the merge of bloom effect
  61336. */
  61337. bloom?: {
  61338. blurred: PostProcess;
  61339. weight: number;
  61340. };
  61341. }
  61342. /**
  61343. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61344. */
  61345. export class DepthOfFieldMergePostProcess extends PostProcess {
  61346. private blurSteps;
  61347. /**
  61348. * Creates a new instance of DepthOfFieldMergePostProcess
  61349. * @param name The name of the effect.
  61350. * @param originalFromInput Post process which's input will be used for the merge.
  61351. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  61352. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  61353. * @param options The required width/height ratio to downsize to before computing the render pass.
  61354. * @param camera The camera to apply the render pass to.
  61355. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61356. * @param engine The engine which the post process will be applied. (default: current engine)
  61357. * @param reusable If the post process can be reused on the same frame. (default: false)
  61358. * @param textureType Type of textures used when performing the post process. (default: 0)
  61359. * @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)
  61360. */
  61361. 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);
  61362. /**
  61363. * Updates the effect with the current post process compile time values and recompiles the shader.
  61364. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  61365. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  61366. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  61367. * @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
  61368. * @param onCompiled Called when the shader has been compiled.
  61369. * @param onError Called if there is an error when compiling a shader.
  61370. */
  61371. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  61372. }
  61373. }
  61374. declare module BABYLON {
  61375. /**
  61376. * Specifies the level of max blur that should be applied when using the depth of field effect
  61377. */
  61378. export enum DepthOfFieldEffectBlurLevel {
  61379. /**
  61380. * Subtle blur
  61381. */
  61382. Low = 0,
  61383. /**
  61384. * Medium blur
  61385. */
  61386. Medium = 1,
  61387. /**
  61388. * Large blur
  61389. */
  61390. High = 2
  61391. }
  61392. /**
  61393. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  61394. */
  61395. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  61396. private _circleOfConfusion;
  61397. /**
  61398. * @hidden Internal, blurs from high to low
  61399. */
  61400. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  61401. private _depthOfFieldBlurY;
  61402. private _dofMerge;
  61403. /**
  61404. * @hidden Internal post processes in depth of field effect
  61405. */
  61406. _effects: Array<PostProcess>;
  61407. /**
  61408. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  61409. */
  61410. focalLength: number;
  61411. /**
  61412. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61413. */
  61414. fStop: number;
  61415. /**
  61416. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61417. */
  61418. focusDistance: number;
  61419. /**
  61420. * 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.
  61421. */
  61422. lensSize: number;
  61423. /**
  61424. * Creates a new instance DepthOfFieldEffect
  61425. * @param scene The scene the effect belongs to.
  61426. * @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.
  61427. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61428. * @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)
  61429. */
  61430. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  61431. /**
  61432. * Get the current class name of the current effet
  61433. * @returns "DepthOfFieldEffect"
  61434. */
  61435. getClassName(): string;
  61436. /**
  61437. * 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.
  61438. */
  61439. depthTexture: RenderTargetTexture;
  61440. /**
  61441. * Disposes each of the internal effects for a given camera.
  61442. * @param camera The camera to dispose the effect on.
  61443. */
  61444. disposeEffects(camera: Camera): void;
  61445. /**
  61446. * @hidden Internal
  61447. */
  61448. _updateEffects(): void;
  61449. /**
  61450. * Internal
  61451. * @returns if all the contained post processes are ready.
  61452. * @hidden
  61453. */
  61454. _isReady(): boolean;
  61455. }
  61456. }
  61457. declare module BABYLON {
  61458. /** @hidden */
  61459. export var displayPassPixelShader: {
  61460. name: string;
  61461. shader: string;
  61462. };
  61463. }
  61464. declare module BABYLON {
  61465. /**
  61466. * DisplayPassPostProcess which produces an output the same as it's input
  61467. */
  61468. export class DisplayPassPostProcess extends PostProcess {
  61469. /**
  61470. * Creates the DisplayPassPostProcess
  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: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61479. }
  61480. }
  61481. declare module BABYLON {
  61482. /** @hidden */
  61483. export var filterPixelShader: {
  61484. name: string;
  61485. shader: string;
  61486. };
  61487. }
  61488. declare module BABYLON {
  61489. /**
  61490. * Applies a kernel filter to the image
  61491. */
  61492. export class FilterPostProcess extends PostProcess {
  61493. /** The matrix to be applied to the image */
  61494. kernelMatrix: Matrix;
  61495. /**
  61496. *
  61497. * @param name The name of the effect.
  61498. * @param kernelMatrix The matrix to be applied to the image
  61499. * @param options The required width/height ratio to downsize to before computing the render pass.
  61500. * @param camera The camera to apply the render pass to.
  61501. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61502. * @param engine The engine which the post process will be applied. (default: current engine)
  61503. * @param reusable If the post process can be reused on the same frame. (default: false)
  61504. */
  61505. constructor(name: string,
  61506. /** The matrix to be applied to the image */
  61507. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61508. }
  61509. }
  61510. declare module BABYLON {
  61511. /** @hidden */
  61512. export var fxaaPixelShader: {
  61513. name: string;
  61514. shader: string;
  61515. };
  61516. }
  61517. declare module BABYLON {
  61518. /** @hidden */
  61519. export var fxaaVertexShader: {
  61520. name: string;
  61521. shader: string;
  61522. };
  61523. }
  61524. declare module BABYLON {
  61525. /**
  61526. * Fxaa post process
  61527. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  61528. */
  61529. export class FxaaPostProcess extends PostProcess {
  61530. /** @hidden */
  61531. texelWidth: number;
  61532. /** @hidden */
  61533. texelHeight: number;
  61534. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61535. private _getDefines;
  61536. }
  61537. }
  61538. declare module BABYLON {
  61539. /** @hidden */
  61540. export var grainPixelShader: {
  61541. name: string;
  61542. shader: string;
  61543. };
  61544. }
  61545. declare module BABYLON {
  61546. /**
  61547. * The GrainPostProcess adds noise to the image at mid luminance levels
  61548. */
  61549. export class GrainPostProcess extends PostProcess {
  61550. /**
  61551. * The intensity of the grain added (default: 30)
  61552. */
  61553. intensity: number;
  61554. /**
  61555. * If the grain should be randomized on every frame
  61556. */
  61557. animated: boolean;
  61558. /**
  61559. * Creates a new instance of @see GrainPostProcess
  61560. * @param name The name of the effect.
  61561. * @param options The required width/height ratio to downsize to before computing the render pass.
  61562. * @param camera The camera to apply the render pass to.
  61563. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61564. * @param engine The engine which the post process will be applied. (default: current engine)
  61565. * @param reusable If the post process can be reused on the same frame. (default: false)
  61566. * @param textureType Type of textures used when performing the post process. (default: 0)
  61567. * @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)
  61568. */
  61569. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61570. }
  61571. }
  61572. declare module BABYLON {
  61573. /** @hidden */
  61574. export var highlightsPixelShader: {
  61575. name: string;
  61576. shader: string;
  61577. };
  61578. }
  61579. declare module BABYLON {
  61580. /**
  61581. * Extracts highlights from the image
  61582. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61583. */
  61584. export class HighlightsPostProcess extends PostProcess {
  61585. /**
  61586. * Extracts highlights from the image
  61587. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61588. * @param name The name of the effect.
  61589. * @param options The required width/height ratio to downsize to before computing the render pass.
  61590. * @param camera The camera to apply the render pass to.
  61591. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61592. * @param engine The engine which the post process will be applied. (default: current engine)
  61593. * @param reusable If the post process can be reused on the same frame. (default: false)
  61594. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  61595. */
  61596. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61597. }
  61598. }
  61599. declare module BABYLON {
  61600. /** @hidden */
  61601. export var mrtFragmentDeclaration: {
  61602. name: string;
  61603. shader: string;
  61604. };
  61605. }
  61606. declare module BABYLON {
  61607. /** @hidden */
  61608. export var geometryPixelShader: {
  61609. name: string;
  61610. shader: string;
  61611. };
  61612. }
  61613. declare module BABYLON {
  61614. /** @hidden */
  61615. export var geometryVertexShader: {
  61616. name: string;
  61617. shader: string;
  61618. };
  61619. }
  61620. declare module BABYLON {
  61621. /** @hidden */
  61622. interface ISavedTransformationMatrix {
  61623. world: Matrix;
  61624. viewProjection: Matrix;
  61625. }
  61626. /**
  61627. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  61628. */
  61629. export class GeometryBufferRenderer {
  61630. /**
  61631. * Constant used to retrieve the position texture index in the G-Buffer textures array
  61632. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  61633. */
  61634. static readonly POSITION_TEXTURE_TYPE: number;
  61635. /**
  61636. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  61637. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  61638. */
  61639. static readonly VELOCITY_TEXTURE_TYPE: number;
  61640. /**
  61641. * Dictionary used to store the previous transformation matrices of each rendered mesh
  61642. * in order to compute objects velocities when enableVelocity is set to "true"
  61643. * @hidden
  61644. */
  61645. _previousTransformationMatrices: {
  61646. [index: number]: ISavedTransformationMatrix;
  61647. };
  61648. /**
  61649. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  61650. * in order to compute objects velocities when enableVelocity is set to "true"
  61651. * @hidden
  61652. */
  61653. _previousBonesTransformationMatrices: {
  61654. [index: number]: Float32Array;
  61655. };
  61656. /**
  61657. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  61658. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  61659. */
  61660. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  61661. private _scene;
  61662. private _multiRenderTarget;
  61663. private _ratio;
  61664. private _enablePosition;
  61665. private _enableVelocity;
  61666. private _positionIndex;
  61667. private _velocityIndex;
  61668. protected _effect: Effect;
  61669. protected _cachedDefines: string;
  61670. /**
  61671. * Set the render list (meshes to be rendered) used in the G buffer.
  61672. */
  61673. renderList: Mesh[];
  61674. /**
  61675. * Gets wether or not G buffer are supported by the running hardware.
  61676. * This requires draw buffer supports
  61677. */
  61678. readonly isSupported: boolean;
  61679. /**
  61680. * Returns the index of the given texture type in the G-Buffer textures array
  61681. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  61682. * @returns the index of the given texture type in the G-Buffer textures array
  61683. */
  61684. getTextureIndex(textureType: number): number;
  61685. /**
  61686. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  61687. */
  61688. /**
  61689. * Sets whether or not objects positions are enabled for the G buffer.
  61690. */
  61691. enablePosition: boolean;
  61692. /**
  61693. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  61694. */
  61695. /**
  61696. * Sets wether or not objects velocities are enabled for the G buffer.
  61697. */
  61698. enableVelocity: boolean;
  61699. /**
  61700. * Gets the scene associated with the buffer.
  61701. */
  61702. readonly scene: Scene;
  61703. /**
  61704. * Gets the ratio used by the buffer during its creation.
  61705. * How big is the buffer related to the main canvas.
  61706. */
  61707. readonly ratio: number;
  61708. /** @hidden */
  61709. static _SceneComponentInitialization: (scene: Scene) => void;
  61710. /**
  61711. * Creates a new G Buffer for the scene
  61712. * @param scene The scene the buffer belongs to
  61713. * @param ratio How big is the buffer related to the main canvas.
  61714. */
  61715. constructor(scene: Scene, ratio?: number);
  61716. /**
  61717. * Checks wether everything is ready to render a submesh to the G buffer.
  61718. * @param subMesh the submesh to check readiness for
  61719. * @param useInstances is the mesh drawn using instance or not
  61720. * @returns true if ready otherwise false
  61721. */
  61722. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61723. /**
  61724. * Gets the current underlying G Buffer.
  61725. * @returns the buffer
  61726. */
  61727. getGBuffer(): MultiRenderTarget;
  61728. /**
  61729. * Gets the number of samples used to render the buffer (anti aliasing).
  61730. */
  61731. /**
  61732. * Sets the number of samples used to render the buffer (anti aliasing).
  61733. */
  61734. samples: number;
  61735. /**
  61736. * Disposes the renderer and frees up associated resources.
  61737. */
  61738. dispose(): void;
  61739. protected _createRenderTargets(): void;
  61740. private _copyBonesTransformationMatrices;
  61741. }
  61742. }
  61743. declare module BABYLON {
  61744. interface Scene {
  61745. /** @hidden (Backing field) */
  61746. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61747. /**
  61748. * Gets or Sets the current geometry buffer associated to the scene.
  61749. */
  61750. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61751. /**
  61752. * Enables a GeometryBufferRender and associates it with the scene
  61753. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  61754. * @returns the GeometryBufferRenderer
  61755. */
  61756. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  61757. /**
  61758. * Disables the GeometryBufferRender associated with the scene
  61759. */
  61760. disableGeometryBufferRenderer(): void;
  61761. }
  61762. /**
  61763. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  61764. * in several rendering techniques.
  61765. */
  61766. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  61767. /**
  61768. * The component name helpful to identify the component in the list of scene components.
  61769. */
  61770. readonly name: string;
  61771. /**
  61772. * The scene the component belongs to.
  61773. */
  61774. scene: Scene;
  61775. /**
  61776. * Creates a new instance of the component for the given scene
  61777. * @param scene Defines the scene to register the component in
  61778. */
  61779. constructor(scene: Scene);
  61780. /**
  61781. * Registers the component in a given scene
  61782. */
  61783. register(): void;
  61784. /**
  61785. * Rebuilds the elements related to this component in case of
  61786. * context lost for instance.
  61787. */
  61788. rebuild(): void;
  61789. /**
  61790. * Disposes the component and the associated ressources
  61791. */
  61792. dispose(): void;
  61793. private _gatherRenderTargets;
  61794. }
  61795. }
  61796. declare module BABYLON {
  61797. /** @hidden */
  61798. export var motionBlurPixelShader: {
  61799. name: string;
  61800. shader: string;
  61801. };
  61802. }
  61803. declare module BABYLON {
  61804. /**
  61805. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  61806. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  61807. * As an example, all you have to do is to create the post-process:
  61808. * var mb = new BABYLON.MotionBlurPostProcess(
  61809. * 'mb', // The name of the effect.
  61810. * scene, // The scene containing the objects to blur according to their velocity.
  61811. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  61812. * camera // The camera to apply the render pass to.
  61813. * );
  61814. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  61815. */
  61816. export class MotionBlurPostProcess extends PostProcess {
  61817. /**
  61818. * Defines how much the image is blurred by the movement. Default value is equal to 1
  61819. */
  61820. motionStrength: number;
  61821. /**
  61822. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  61823. */
  61824. /**
  61825. * Sets the number of iterations to be used for motion blur quality
  61826. */
  61827. motionBlurSamples: number;
  61828. private _motionBlurSamples;
  61829. private _geometryBufferRenderer;
  61830. /**
  61831. * Creates a new instance MotionBlurPostProcess
  61832. * @param name The name of the effect.
  61833. * @param scene The scene containing the objects to blur according to their velocity.
  61834. * @param options The required width/height ratio to downsize to before computing the render pass.
  61835. * @param camera The camera to apply the render pass to.
  61836. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61837. * @param engine The engine which the post process will be applied. (default: current engine)
  61838. * @param reusable If the post process can be reused on the same frame. (default: false)
  61839. * @param textureType Type of textures used when performing the post process. (default: 0)
  61840. * @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)
  61841. */
  61842. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61843. /**
  61844. * Excludes the given skinned mesh from computing bones velocities.
  61845. * 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.
  61846. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  61847. */
  61848. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61849. /**
  61850. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  61851. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  61852. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  61853. */
  61854. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61855. /**
  61856. * Disposes the post process.
  61857. * @param camera The camera to dispose the post process on.
  61858. */
  61859. dispose(camera?: Camera): void;
  61860. }
  61861. }
  61862. declare module BABYLON {
  61863. /** @hidden */
  61864. export var refractionPixelShader: {
  61865. name: string;
  61866. shader: string;
  61867. };
  61868. }
  61869. declare module BABYLON {
  61870. /**
  61871. * Post process which applies a refractin texture
  61872. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61873. */
  61874. export class RefractionPostProcess extends PostProcess {
  61875. /** the base color of the refraction (used to taint the rendering) */
  61876. color: Color3;
  61877. /** simulated refraction depth */
  61878. depth: number;
  61879. /** the coefficient of the base color (0 to remove base color tainting) */
  61880. colorLevel: number;
  61881. private _refTexture;
  61882. private _ownRefractionTexture;
  61883. /**
  61884. * Gets or sets the refraction texture
  61885. * Please note that you are responsible for disposing the texture if you set it manually
  61886. */
  61887. refractionTexture: Texture;
  61888. /**
  61889. * Initializes the RefractionPostProcess
  61890. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61891. * @param name The name of the effect.
  61892. * @param refractionTextureUrl Url of the refraction texture to use
  61893. * @param color the base color of the refraction (used to taint the rendering)
  61894. * @param depth simulated refraction depth
  61895. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  61896. * @param camera The camera to apply the render pass to.
  61897. * @param options The required width/height ratio to downsize to before computing the render pass.
  61898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61899. * @param engine The engine which the post process will be applied. (default: current engine)
  61900. * @param reusable If the post process can be reused on the same frame. (default: false)
  61901. */
  61902. constructor(name: string, refractionTextureUrl: string,
  61903. /** the base color of the refraction (used to taint the rendering) */
  61904. color: Color3,
  61905. /** simulated refraction depth */
  61906. depth: number,
  61907. /** the coefficient of the base color (0 to remove base color tainting) */
  61908. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61909. /**
  61910. * Disposes of the post process
  61911. * @param camera Camera to dispose post process on
  61912. */
  61913. dispose(camera: Camera): void;
  61914. }
  61915. }
  61916. declare module BABYLON {
  61917. /** @hidden */
  61918. export var sharpenPixelShader: {
  61919. name: string;
  61920. shader: string;
  61921. };
  61922. }
  61923. declare module BABYLON {
  61924. /**
  61925. * The SharpenPostProcess applies a sharpen kernel to every pixel
  61926. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61927. */
  61928. export class SharpenPostProcess extends PostProcess {
  61929. /**
  61930. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  61931. */
  61932. colorAmount: number;
  61933. /**
  61934. * How much sharpness should be applied (default: 0.3)
  61935. */
  61936. edgeAmount: number;
  61937. /**
  61938. * Creates a new instance ConvolutionPostProcess
  61939. * @param name The name of the effect.
  61940. * @param options The required width/height ratio to downsize to before computing the render pass.
  61941. * @param camera The camera to apply the render pass to.
  61942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61943. * @param engine The engine which the post process will be applied. (default: current engine)
  61944. * @param reusable If the post process can be reused on the same frame. (default: false)
  61945. * @param textureType Type of textures used when performing the post process. (default: 0)
  61946. * @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)
  61947. */
  61948. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61949. }
  61950. }
  61951. declare module BABYLON {
  61952. /**
  61953. * PostProcessRenderPipeline
  61954. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61955. */
  61956. export class PostProcessRenderPipeline {
  61957. private engine;
  61958. private _renderEffects;
  61959. private _renderEffectsForIsolatedPass;
  61960. /**
  61961. * List of inspectable custom properties (used by the Inspector)
  61962. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  61963. */
  61964. inspectableCustomProperties: IInspectable[];
  61965. /**
  61966. * @hidden
  61967. */
  61968. protected _cameras: Camera[];
  61969. /** @hidden */
  61970. _name: string;
  61971. /**
  61972. * Gets pipeline name
  61973. */
  61974. readonly name: string;
  61975. /** Gets the list of attached cameras */
  61976. readonly cameras: Camera[];
  61977. /**
  61978. * Initializes a PostProcessRenderPipeline
  61979. * @param engine engine to add the pipeline to
  61980. * @param name name of the pipeline
  61981. */
  61982. constructor(engine: Engine, name: string);
  61983. /**
  61984. * Gets the class name
  61985. * @returns "PostProcessRenderPipeline"
  61986. */
  61987. getClassName(): string;
  61988. /**
  61989. * If all the render effects in the pipeline are supported
  61990. */
  61991. readonly isSupported: boolean;
  61992. /**
  61993. * Adds an effect to the pipeline
  61994. * @param renderEffect the effect to add
  61995. */
  61996. addEffect(renderEffect: PostProcessRenderEffect): void;
  61997. /** @hidden */
  61998. _rebuild(): void;
  61999. /** @hidden */
  62000. _enableEffect(renderEffectName: string, cameras: Camera): void;
  62001. /** @hidden */
  62002. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  62003. /** @hidden */
  62004. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62005. /** @hidden */
  62006. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62007. /** @hidden */
  62008. _attachCameras(cameras: Camera, unique: boolean): void;
  62009. /** @hidden */
  62010. _attachCameras(cameras: Camera[], unique: boolean): void;
  62011. /** @hidden */
  62012. _detachCameras(cameras: Camera): void;
  62013. /** @hidden */
  62014. _detachCameras(cameras: Nullable<Camera[]>): void;
  62015. /** @hidden */
  62016. _update(): void;
  62017. /** @hidden */
  62018. _reset(): void;
  62019. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  62020. /**
  62021. * Disposes of the pipeline
  62022. */
  62023. dispose(): void;
  62024. }
  62025. }
  62026. declare module BABYLON {
  62027. /**
  62028. * PostProcessRenderPipelineManager class
  62029. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62030. */
  62031. export class PostProcessRenderPipelineManager {
  62032. private _renderPipelines;
  62033. /**
  62034. * Initializes a PostProcessRenderPipelineManager
  62035. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62036. */
  62037. constructor();
  62038. /**
  62039. * Gets the list of supported render pipelines
  62040. */
  62041. readonly supportedPipelines: PostProcessRenderPipeline[];
  62042. /**
  62043. * Adds a pipeline to the manager
  62044. * @param renderPipeline The pipeline to add
  62045. */
  62046. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  62047. /**
  62048. * Attaches a camera to the pipeline
  62049. * @param renderPipelineName The name of the pipeline to attach to
  62050. * @param cameras the camera to attach
  62051. * @param unique if the camera can be attached multiple times to the pipeline
  62052. */
  62053. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  62054. /**
  62055. * Detaches a camera from the pipeline
  62056. * @param renderPipelineName The name of the pipeline to detach from
  62057. * @param cameras the camera to detach
  62058. */
  62059. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  62060. /**
  62061. * Enables an effect by name on a pipeline
  62062. * @param renderPipelineName the name of the pipeline to enable the effect in
  62063. * @param renderEffectName the name of the effect to enable
  62064. * @param cameras the cameras that the effect should be enabled on
  62065. */
  62066. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62067. /**
  62068. * Disables an effect by name on a pipeline
  62069. * @param renderPipelineName the name of the pipeline to disable the effect in
  62070. * @param renderEffectName the name of the effect to disable
  62071. * @param cameras the cameras that the effect should be disabled on
  62072. */
  62073. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62074. /**
  62075. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  62076. */
  62077. update(): void;
  62078. /** @hidden */
  62079. _rebuild(): void;
  62080. /**
  62081. * Disposes of the manager and pipelines
  62082. */
  62083. dispose(): void;
  62084. }
  62085. }
  62086. declare module BABYLON {
  62087. interface Scene {
  62088. /** @hidden (Backing field) */
  62089. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62090. /**
  62091. * Gets the postprocess render pipeline manager
  62092. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62093. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62094. */
  62095. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62096. }
  62097. /**
  62098. * Defines the Render Pipeline scene component responsible to rendering pipelines
  62099. */
  62100. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  62101. /**
  62102. * The component name helpfull to identify the component in the list of scene components.
  62103. */
  62104. readonly name: string;
  62105. /**
  62106. * The scene the component belongs to.
  62107. */
  62108. scene: Scene;
  62109. /**
  62110. * Creates a new instance of the component for the given scene
  62111. * @param scene Defines the scene to register the component in
  62112. */
  62113. constructor(scene: Scene);
  62114. /**
  62115. * Registers the component in a given scene
  62116. */
  62117. register(): void;
  62118. /**
  62119. * Rebuilds the elements related to this component in case of
  62120. * context lost for instance.
  62121. */
  62122. rebuild(): void;
  62123. /**
  62124. * Disposes the component and the associated ressources
  62125. */
  62126. dispose(): void;
  62127. private _gatherRenderTargets;
  62128. }
  62129. }
  62130. declare module BABYLON {
  62131. /**
  62132. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  62133. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62134. */
  62135. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62136. private _scene;
  62137. private _camerasToBeAttached;
  62138. /**
  62139. * ID of the sharpen post process,
  62140. */
  62141. private readonly SharpenPostProcessId;
  62142. /**
  62143. * @ignore
  62144. * ID of the image processing post process;
  62145. */
  62146. readonly ImageProcessingPostProcessId: string;
  62147. /**
  62148. * @ignore
  62149. * ID of the Fast Approximate Anti-Aliasing post process;
  62150. */
  62151. readonly FxaaPostProcessId: string;
  62152. /**
  62153. * ID of the chromatic aberration post process,
  62154. */
  62155. private readonly ChromaticAberrationPostProcessId;
  62156. /**
  62157. * ID of the grain post process
  62158. */
  62159. private readonly GrainPostProcessId;
  62160. /**
  62161. * Sharpen post process which will apply a sharpen convolution to enhance edges
  62162. */
  62163. sharpen: SharpenPostProcess;
  62164. private _sharpenEffect;
  62165. private bloom;
  62166. /**
  62167. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  62168. */
  62169. depthOfField: DepthOfFieldEffect;
  62170. /**
  62171. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62172. */
  62173. fxaa: FxaaPostProcess;
  62174. /**
  62175. * Image post processing pass used to perform operations such as tone mapping or color grading.
  62176. */
  62177. imageProcessing: ImageProcessingPostProcess;
  62178. /**
  62179. * Chromatic aberration post process which will shift rgb colors in the image
  62180. */
  62181. chromaticAberration: ChromaticAberrationPostProcess;
  62182. private _chromaticAberrationEffect;
  62183. /**
  62184. * Grain post process which add noise to the image
  62185. */
  62186. grain: GrainPostProcess;
  62187. private _grainEffect;
  62188. /**
  62189. * Glow post process which adds a glow to emissive areas of the image
  62190. */
  62191. private _glowLayer;
  62192. /**
  62193. * Animations which can be used to tweak settings over a period of time
  62194. */
  62195. animations: Animation[];
  62196. private _imageProcessingConfigurationObserver;
  62197. private _sharpenEnabled;
  62198. private _bloomEnabled;
  62199. private _depthOfFieldEnabled;
  62200. private _depthOfFieldBlurLevel;
  62201. private _fxaaEnabled;
  62202. private _imageProcessingEnabled;
  62203. private _defaultPipelineTextureType;
  62204. private _bloomScale;
  62205. private _chromaticAberrationEnabled;
  62206. private _grainEnabled;
  62207. private _buildAllowed;
  62208. /**
  62209. * Gets active scene
  62210. */
  62211. readonly scene: Scene;
  62212. /**
  62213. * Enable or disable the sharpen process from the pipeline
  62214. */
  62215. sharpenEnabled: boolean;
  62216. private _resizeObserver;
  62217. private _hardwareScaleLevel;
  62218. private _bloomKernel;
  62219. /**
  62220. * Specifies the size of the bloom blur kernel, relative to the final output size
  62221. */
  62222. bloomKernel: number;
  62223. /**
  62224. * Specifies the weight of the bloom in the final rendering
  62225. */
  62226. private _bloomWeight;
  62227. /**
  62228. * Specifies the luma threshold for the area that will be blurred by the bloom
  62229. */
  62230. private _bloomThreshold;
  62231. private _hdr;
  62232. /**
  62233. * The strength of the bloom.
  62234. */
  62235. bloomWeight: number;
  62236. /**
  62237. * The strength of the bloom.
  62238. */
  62239. bloomThreshold: number;
  62240. /**
  62241. * The scale of the bloom, lower value will provide better performance.
  62242. */
  62243. bloomScale: number;
  62244. /**
  62245. * Enable or disable the bloom from the pipeline
  62246. */
  62247. bloomEnabled: boolean;
  62248. private _rebuildBloom;
  62249. /**
  62250. * If the depth of field is enabled.
  62251. */
  62252. depthOfFieldEnabled: boolean;
  62253. /**
  62254. * Blur level of the depth of field effect. (Higher blur will effect performance)
  62255. */
  62256. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  62257. /**
  62258. * If the anti aliasing is enabled.
  62259. */
  62260. fxaaEnabled: boolean;
  62261. private _samples;
  62262. /**
  62263. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62264. */
  62265. samples: number;
  62266. /**
  62267. * If image processing is enabled.
  62268. */
  62269. imageProcessingEnabled: boolean;
  62270. /**
  62271. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  62272. */
  62273. glowLayerEnabled: boolean;
  62274. /**
  62275. * Gets the glow layer (or null if not defined)
  62276. */
  62277. readonly glowLayer: Nullable<GlowLayer>;
  62278. /**
  62279. * Enable or disable the chromaticAberration process from the pipeline
  62280. */
  62281. chromaticAberrationEnabled: boolean;
  62282. /**
  62283. * Enable or disable the grain process from the pipeline
  62284. */
  62285. grainEnabled: boolean;
  62286. /**
  62287. * @constructor
  62288. * @param name - The rendering pipeline name (default: "")
  62289. * @param hdr - If high dynamic range textures should be used (default: true)
  62290. * @param scene - The scene linked to this pipeline (default: the last created scene)
  62291. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  62292. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  62293. */
  62294. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  62295. /**
  62296. * Get the class name
  62297. * @returns "DefaultRenderingPipeline"
  62298. */
  62299. getClassName(): string;
  62300. /**
  62301. * Force the compilation of the entire pipeline.
  62302. */
  62303. prepare(): void;
  62304. private _hasCleared;
  62305. private _prevPostProcess;
  62306. private _prevPrevPostProcess;
  62307. private _setAutoClearAndTextureSharing;
  62308. private _depthOfFieldSceneObserver;
  62309. private _buildPipeline;
  62310. private _disposePostProcesses;
  62311. /**
  62312. * Adds a camera to the pipeline
  62313. * @param camera the camera to be added
  62314. */
  62315. addCamera(camera: Camera): void;
  62316. /**
  62317. * Removes a camera from the pipeline
  62318. * @param camera the camera to remove
  62319. */
  62320. removeCamera(camera: Camera): void;
  62321. /**
  62322. * Dispose of the pipeline and stop all post processes
  62323. */
  62324. dispose(): void;
  62325. /**
  62326. * Serialize the rendering pipeline (Used when exporting)
  62327. * @returns the serialized object
  62328. */
  62329. serialize(): any;
  62330. /**
  62331. * Parse the serialized pipeline
  62332. * @param source Source pipeline.
  62333. * @param scene The scene to load the pipeline to.
  62334. * @param rootUrl The URL of the serialized pipeline.
  62335. * @returns An instantiated pipeline from the serialized object.
  62336. */
  62337. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  62338. }
  62339. }
  62340. declare module BABYLON {
  62341. /** @hidden */
  62342. export var lensHighlightsPixelShader: {
  62343. name: string;
  62344. shader: string;
  62345. };
  62346. }
  62347. declare module BABYLON {
  62348. /** @hidden */
  62349. export var depthOfFieldPixelShader: {
  62350. name: string;
  62351. shader: string;
  62352. };
  62353. }
  62354. declare module BABYLON {
  62355. /**
  62356. * BABYLON.JS Chromatic Aberration GLSL Shader
  62357. * Author: Olivier Guyot
  62358. * Separates very slightly R, G and B colors on the edges of the screen
  62359. * Inspired by Francois Tarlier & Martins Upitis
  62360. */
  62361. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  62362. /**
  62363. * @ignore
  62364. * The chromatic aberration PostProcess id in the pipeline
  62365. */
  62366. LensChromaticAberrationEffect: string;
  62367. /**
  62368. * @ignore
  62369. * The highlights enhancing PostProcess id in the pipeline
  62370. */
  62371. HighlightsEnhancingEffect: string;
  62372. /**
  62373. * @ignore
  62374. * The depth-of-field PostProcess id in the pipeline
  62375. */
  62376. LensDepthOfFieldEffect: string;
  62377. private _scene;
  62378. private _depthTexture;
  62379. private _grainTexture;
  62380. private _chromaticAberrationPostProcess;
  62381. private _highlightsPostProcess;
  62382. private _depthOfFieldPostProcess;
  62383. private _edgeBlur;
  62384. private _grainAmount;
  62385. private _chromaticAberration;
  62386. private _distortion;
  62387. private _highlightsGain;
  62388. private _highlightsThreshold;
  62389. private _dofDistance;
  62390. private _dofAperture;
  62391. private _dofDarken;
  62392. private _dofPentagon;
  62393. private _blurNoise;
  62394. /**
  62395. * @constructor
  62396. *
  62397. * Effect parameters are as follow:
  62398. * {
  62399. * chromatic_aberration: number; // from 0 to x (1 for realism)
  62400. * edge_blur: number; // from 0 to x (1 for realism)
  62401. * distortion: number; // from 0 to x (1 for realism)
  62402. * grain_amount: number; // from 0 to 1
  62403. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  62404. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  62405. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  62406. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  62407. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  62408. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  62409. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  62410. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  62411. * }
  62412. * Note: if an effect parameter is unset, effect is disabled
  62413. *
  62414. * @param name The rendering pipeline name
  62415. * @param parameters - An object containing all parameters (see above)
  62416. * @param scene The scene linked to this pipeline
  62417. * @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)
  62418. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62419. */
  62420. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  62421. /**
  62422. * Get the class name
  62423. * @returns "LensRenderingPipeline"
  62424. */
  62425. getClassName(): string;
  62426. /**
  62427. * Gets associated scene
  62428. */
  62429. readonly scene: Scene;
  62430. /**
  62431. * Gets or sets the edge blur
  62432. */
  62433. edgeBlur: number;
  62434. /**
  62435. * Gets or sets the grain amount
  62436. */
  62437. grainAmount: number;
  62438. /**
  62439. * Gets or sets the chromatic aberration amount
  62440. */
  62441. chromaticAberration: number;
  62442. /**
  62443. * Gets or sets the depth of field aperture
  62444. */
  62445. dofAperture: number;
  62446. /**
  62447. * Gets or sets the edge distortion
  62448. */
  62449. edgeDistortion: number;
  62450. /**
  62451. * Gets or sets the depth of field distortion
  62452. */
  62453. dofDistortion: number;
  62454. /**
  62455. * Gets or sets the darken out of focus amount
  62456. */
  62457. darkenOutOfFocus: number;
  62458. /**
  62459. * Gets or sets a boolean indicating if blur noise is enabled
  62460. */
  62461. blurNoise: boolean;
  62462. /**
  62463. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  62464. */
  62465. pentagonBokeh: boolean;
  62466. /**
  62467. * Gets or sets the highlight grain amount
  62468. */
  62469. highlightsGain: number;
  62470. /**
  62471. * Gets or sets the highlight threshold
  62472. */
  62473. highlightsThreshold: number;
  62474. /**
  62475. * Sets the amount of blur at the edges
  62476. * @param amount blur amount
  62477. */
  62478. setEdgeBlur(amount: number): void;
  62479. /**
  62480. * Sets edge blur to 0
  62481. */
  62482. disableEdgeBlur(): void;
  62483. /**
  62484. * Sets the amout of grain
  62485. * @param amount Amount of grain
  62486. */
  62487. setGrainAmount(amount: number): void;
  62488. /**
  62489. * Set grain amount to 0
  62490. */
  62491. disableGrain(): void;
  62492. /**
  62493. * Sets the chromatic aberration amount
  62494. * @param amount amount of chromatic aberration
  62495. */
  62496. setChromaticAberration(amount: number): void;
  62497. /**
  62498. * Sets chromatic aberration amount to 0
  62499. */
  62500. disableChromaticAberration(): void;
  62501. /**
  62502. * Sets the EdgeDistortion amount
  62503. * @param amount amount of EdgeDistortion
  62504. */
  62505. setEdgeDistortion(amount: number): void;
  62506. /**
  62507. * Sets edge distortion to 0
  62508. */
  62509. disableEdgeDistortion(): void;
  62510. /**
  62511. * Sets the FocusDistance amount
  62512. * @param amount amount of FocusDistance
  62513. */
  62514. setFocusDistance(amount: number): void;
  62515. /**
  62516. * Disables depth of field
  62517. */
  62518. disableDepthOfField(): void;
  62519. /**
  62520. * Sets the Aperture amount
  62521. * @param amount amount of Aperture
  62522. */
  62523. setAperture(amount: number): void;
  62524. /**
  62525. * Sets the DarkenOutOfFocus amount
  62526. * @param amount amount of DarkenOutOfFocus
  62527. */
  62528. setDarkenOutOfFocus(amount: number): void;
  62529. private _pentagonBokehIsEnabled;
  62530. /**
  62531. * Creates a pentagon bokeh effect
  62532. */
  62533. enablePentagonBokeh(): void;
  62534. /**
  62535. * Disables the pentagon bokeh effect
  62536. */
  62537. disablePentagonBokeh(): void;
  62538. /**
  62539. * Enables noise blur
  62540. */
  62541. enableNoiseBlur(): void;
  62542. /**
  62543. * Disables noise blur
  62544. */
  62545. disableNoiseBlur(): void;
  62546. /**
  62547. * Sets the HighlightsGain amount
  62548. * @param amount amount of HighlightsGain
  62549. */
  62550. setHighlightsGain(amount: number): void;
  62551. /**
  62552. * Sets the HighlightsThreshold amount
  62553. * @param amount amount of HighlightsThreshold
  62554. */
  62555. setHighlightsThreshold(amount: number): void;
  62556. /**
  62557. * Disables highlights
  62558. */
  62559. disableHighlights(): void;
  62560. /**
  62561. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  62562. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  62563. */
  62564. dispose(disableDepthRender?: boolean): void;
  62565. private _createChromaticAberrationPostProcess;
  62566. private _createHighlightsPostProcess;
  62567. private _createDepthOfFieldPostProcess;
  62568. private _createGrainTexture;
  62569. }
  62570. }
  62571. declare module BABYLON {
  62572. /** @hidden */
  62573. export var ssao2PixelShader: {
  62574. name: string;
  62575. shader: string;
  62576. };
  62577. }
  62578. declare module BABYLON {
  62579. /** @hidden */
  62580. export var ssaoCombinePixelShader: {
  62581. name: string;
  62582. shader: string;
  62583. };
  62584. }
  62585. declare module BABYLON {
  62586. /**
  62587. * Render pipeline to produce ssao effect
  62588. */
  62589. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  62590. /**
  62591. * @ignore
  62592. * The PassPostProcess id in the pipeline that contains the original scene color
  62593. */
  62594. SSAOOriginalSceneColorEffect: string;
  62595. /**
  62596. * @ignore
  62597. * The SSAO PostProcess id in the pipeline
  62598. */
  62599. SSAORenderEffect: string;
  62600. /**
  62601. * @ignore
  62602. * The horizontal blur PostProcess id in the pipeline
  62603. */
  62604. SSAOBlurHRenderEffect: string;
  62605. /**
  62606. * @ignore
  62607. * The vertical blur PostProcess id in the pipeline
  62608. */
  62609. SSAOBlurVRenderEffect: string;
  62610. /**
  62611. * @ignore
  62612. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62613. */
  62614. SSAOCombineRenderEffect: string;
  62615. /**
  62616. * The output strength of the SSAO post-process. Default value is 1.0.
  62617. */
  62618. totalStrength: number;
  62619. /**
  62620. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  62621. */
  62622. maxZ: number;
  62623. /**
  62624. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  62625. */
  62626. minZAspect: number;
  62627. private _samples;
  62628. /**
  62629. * Number of samples used for the SSAO calculations. Default value is 8
  62630. */
  62631. samples: number;
  62632. private _textureSamples;
  62633. /**
  62634. * Number of samples to use for antialiasing
  62635. */
  62636. textureSamples: number;
  62637. /**
  62638. * Ratio object used for SSAO ratio and blur ratio
  62639. */
  62640. private _ratio;
  62641. /**
  62642. * Dynamically generated sphere sampler.
  62643. */
  62644. private _sampleSphere;
  62645. /**
  62646. * Blur filter offsets
  62647. */
  62648. private _samplerOffsets;
  62649. private _expensiveBlur;
  62650. /**
  62651. * If bilateral blur should be used
  62652. */
  62653. expensiveBlur: boolean;
  62654. /**
  62655. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  62656. */
  62657. radius: number;
  62658. /**
  62659. * The base color of the SSAO post-process
  62660. * The final result is "base + ssao" between [0, 1]
  62661. */
  62662. base: number;
  62663. /**
  62664. * Support test.
  62665. */
  62666. static readonly IsSupported: boolean;
  62667. private _scene;
  62668. private _depthTexture;
  62669. private _normalTexture;
  62670. private _randomTexture;
  62671. private _originalColorPostProcess;
  62672. private _ssaoPostProcess;
  62673. private _blurHPostProcess;
  62674. private _blurVPostProcess;
  62675. private _ssaoCombinePostProcess;
  62676. /**
  62677. * Gets active scene
  62678. */
  62679. readonly scene: Scene;
  62680. /**
  62681. * @constructor
  62682. * @param name The rendering pipeline name
  62683. * @param scene The scene linked to this pipeline
  62684. * @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 }
  62685. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62686. */
  62687. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62688. /**
  62689. * Get the class name
  62690. * @returns "SSAO2RenderingPipeline"
  62691. */
  62692. getClassName(): string;
  62693. /**
  62694. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62695. */
  62696. dispose(disableGeometryBufferRenderer?: boolean): void;
  62697. private _createBlurPostProcess;
  62698. /** @hidden */
  62699. _rebuild(): void;
  62700. private _bits;
  62701. private _radicalInverse_VdC;
  62702. private _hammersley;
  62703. private _hemisphereSample_uniform;
  62704. private _generateHemisphere;
  62705. private _createSSAOPostProcess;
  62706. private _createSSAOCombinePostProcess;
  62707. private _createRandomTexture;
  62708. /**
  62709. * Serialize the rendering pipeline (Used when exporting)
  62710. * @returns the serialized object
  62711. */
  62712. serialize(): any;
  62713. /**
  62714. * Parse the serialized pipeline
  62715. * @param source Source pipeline.
  62716. * @param scene The scene to load the pipeline to.
  62717. * @param rootUrl The URL of the serialized pipeline.
  62718. * @returns An instantiated pipeline from the serialized object.
  62719. */
  62720. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  62721. }
  62722. }
  62723. declare module BABYLON {
  62724. /** @hidden */
  62725. export var ssaoPixelShader: {
  62726. name: string;
  62727. shader: string;
  62728. };
  62729. }
  62730. declare module BABYLON {
  62731. /**
  62732. * Render pipeline to produce ssao effect
  62733. */
  62734. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  62735. /**
  62736. * @ignore
  62737. * The PassPostProcess id in the pipeline that contains the original scene color
  62738. */
  62739. SSAOOriginalSceneColorEffect: string;
  62740. /**
  62741. * @ignore
  62742. * The SSAO PostProcess id in the pipeline
  62743. */
  62744. SSAORenderEffect: string;
  62745. /**
  62746. * @ignore
  62747. * The horizontal blur PostProcess id in the pipeline
  62748. */
  62749. SSAOBlurHRenderEffect: string;
  62750. /**
  62751. * @ignore
  62752. * The vertical blur PostProcess id in the pipeline
  62753. */
  62754. SSAOBlurVRenderEffect: string;
  62755. /**
  62756. * @ignore
  62757. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62758. */
  62759. SSAOCombineRenderEffect: string;
  62760. /**
  62761. * The output strength of the SSAO post-process. Default value is 1.0.
  62762. */
  62763. totalStrength: number;
  62764. /**
  62765. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  62766. */
  62767. radius: number;
  62768. /**
  62769. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  62770. * Must not be equal to fallOff and superior to fallOff.
  62771. * Default value is 0.0075
  62772. */
  62773. area: number;
  62774. /**
  62775. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  62776. * Must not be equal to area and inferior to area.
  62777. * Default value is 0.000001
  62778. */
  62779. fallOff: number;
  62780. /**
  62781. * The base color of the SSAO post-process
  62782. * The final result is "base + ssao" between [0, 1]
  62783. */
  62784. base: number;
  62785. private _scene;
  62786. private _depthTexture;
  62787. private _randomTexture;
  62788. private _originalColorPostProcess;
  62789. private _ssaoPostProcess;
  62790. private _blurHPostProcess;
  62791. private _blurVPostProcess;
  62792. private _ssaoCombinePostProcess;
  62793. private _firstUpdate;
  62794. /**
  62795. * Gets active scene
  62796. */
  62797. readonly scene: Scene;
  62798. /**
  62799. * @constructor
  62800. * @param name - The rendering pipeline name
  62801. * @param scene - The scene linked to this pipeline
  62802. * @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 }
  62803. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  62804. */
  62805. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62806. /**
  62807. * Get the class name
  62808. * @returns "SSAORenderingPipeline"
  62809. */
  62810. getClassName(): string;
  62811. /**
  62812. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62813. */
  62814. dispose(disableDepthRender?: boolean): void;
  62815. private _createBlurPostProcess;
  62816. /** @hidden */
  62817. _rebuild(): void;
  62818. private _createSSAOPostProcess;
  62819. private _createSSAOCombinePostProcess;
  62820. private _createRandomTexture;
  62821. }
  62822. }
  62823. declare module BABYLON {
  62824. /** @hidden */
  62825. export var standardPixelShader: {
  62826. name: string;
  62827. shader: string;
  62828. };
  62829. }
  62830. declare module BABYLON {
  62831. /**
  62832. * Standard rendering pipeline
  62833. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62834. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  62835. */
  62836. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62837. /**
  62838. * Public members
  62839. */
  62840. /**
  62841. * Post-process which contains the original scene color before the pipeline applies all the effects
  62842. */
  62843. originalPostProcess: Nullable<PostProcess>;
  62844. /**
  62845. * Post-process used to down scale an image x4
  62846. */
  62847. downSampleX4PostProcess: Nullable<PostProcess>;
  62848. /**
  62849. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  62850. */
  62851. brightPassPostProcess: Nullable<PostProcess>;
  62852. /**
  62853. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  62854. */
  62855. blurHPostProcesses: PostProcess[];
  62856. /**
  62857. * Post-process array storing all the vertical blur post-processes used by the pipeline
  62858. */
  62859. blurVPostProcesses: PostProcess[];
  62860. /**
  62861. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  62862. */
  62863. textureAdderPostProcess: Nullable<PostProcess>;
  62864. /**
  62865. * Post-process used to create volumetric lighting effect
  62866. */
  62867. volumetricLightPostProcess: Nullable<PostProcess>;
  62868. /**
  62869. * Post-process used to smooth the previous volumetric light post-process on the X axis
  62870. */
  62871. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  62872. /**
  62873. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  62874. */
  62875. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  62876. /**
  62877. * Post-process used to merge the volumetric light effect and the real scene color
  62878. */
  62879. volumetricLightMergePostProces: Nullable<PostProcess>;
  62880. /**
  62881. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  62882. */
  62883. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  62884. /**
  62885. * Base post-process used to calculate the average luminance of the final image for HDR
  62886. */
  62887. luminancePostProcess: Nullable<PostProcess>;
  62888. /**
  62889. * Post-processes used to create down sample post-processes in order to get
  62890. * the average luminance of the final image for HDR
  62891. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  62892. */
  62893. luminanceDownSamplePostProcesses: PostProcess[];
  62894. /**
  62895. * Post-process used to create a HDR effect (light adaptation)
  62896. */
  62897. hdrPostProcess: Nullable<PostProcess>;
  62898. /**
  62899. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  62900. */
  62901. textureAdderFinalPostProcess: Nullable<PostProcess>;
  62902. /**
  62903. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  62904. */
  62905. lensFlareFinalPostProcess: Nullable<PostProcess>;
  62906. /**
  62907. * Post-process used to merge the final HDR post-process and the real scene color
  62908. */
  62909. hdrFinalPostProcess: Nullable<PostProcess>;
  62910. /**
  62911. * Post-process used to create a lens flare effect
  62912. */
  62913. lensFlarePostProcess: Nullable<PostProcess>;
  62914. /**
  62915. * Post-process that merges the result of the lens flare post-process and the real scene color
  62916. */
  62917. lensFlareComposePostProcess: Nullable<PostProcess>;
  62918. /**
  62919. * Post-process used to create a motion blur effect
  62920. */
  62921. motionBlurPostProcess: Nullable<PostProcess>;
  62922. /**
  62923. * Post-process used to create a depth of field effect
  62924. */
  62925. depthOfFieldPostProcess: Nullable<PostProcess>;
  62926. /**
  62927. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62928. */
  62929. fxaaPostProcess: Nullable<FxaaPostProcess>;
  62930. /**
  62931. * Represents the brightness threshold in order to configure the illuminated surfaces
  62932. */
  62933. brightThreshold: number;
  62934. /**
  62935. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  62936. */
  62937. blurWidth: number;
  62938. /**
  62939. * Sets if the blur for highlighted surfaces must be only horizontal
  62940. */
  62941. horizontalBlur: boolean;
  62942. /**
  62943. * Gets the overall exposure used by the pipeline
  62944. */
  62945. /**
  62946. * Sets the overall exposure used by the pipeline
  62947. */
  62948. exposure: number;
  62949. /**
  62950. * Texture used typically to simulate "dirty" on camera lens
  62951. */
  62952. lensTexture: Nullable<Texture>;
  62953. /**
  62954. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  62955. */
  62956. volumetricLightCoefficient: number;
  62957. /**
  62958. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  62959. */
  62960. volumetricLightPower: number;
  62961. /**
  62962. * Used the set the blur intensity to smooth the volumetric lights
  62963. */
  62964. volumetricLightBlurScale: number;
  62965. /**
  62966. * Light (spot or directional) used to generate the volumetric lights rays
  62967. * The source light must have a shadow generate so the pipeline can get its
  62968. * depth map
  62969. */
  62970. sourceLight: Nullable<SpotLight | DirectionalLight>;
  62971. /**
  62972. * For eye adaptation, represents the minimum luminance the eye can see
  62973. */
  62974. hdrMinimumLuminance: number;
  62975. /**
  62976. * For eye adaptation, represents the decrease luminance speed
  62977. */
  62978. hdrDecreaseRate: number;
  62979. /**
  62980. * For eye adaptation, represents the increase luminance speed
  62981. */
  62982. hdrIncreaseRate: number;
  62983. /**
  62984. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  62985. */
  62986. /**
  62987. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  62988. */
  62989. hdrAutoExposure: boolean;
  62990. /**
  62991. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  62992. */
  62993. lensColorTexture: Nullable<Texture>;
  62994. /**
  62995. * The overall strengh for the lens flare effect
  62996. */
  62997. lensFlareStrength: number;
  62998. /**
  62999. * Dispersion coefficient for lens flare ghosts
  63000. */
  63001. lensFlareGhostDispersal: number;
  63002. /**
  63003. * Main lens flare halo width
  63004. */
  63005. lensFlareHaloWidth: number;
  63006. /**
  63007. * Based on the lens distortion effect, defines how much the lens flare result
  63008. * is distorted
  63009. */
  63010. lensFlareDistortionStrength: number;
  63011. /**
  63012. * Configures the blur intensity used for for lens flare (halo)
  63013. */
  63014. lensFlareBlurWidth: number;
  63015. /**
  63016. * Lens star texture must be used to simulate rays on the flares and is available
  63017. * in the documentation
  63018. */
  63019. lensStarTexture: Nullable<Texture>;
  63020. /**
  63021. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  63022. * flare effect by taking account of the dirt texture
  63023. */
  63024. lensFlareDirtTexture: Nullable<Texture>;
  63025. /**
  63026. * Represents the focal length for the depth of field effect
  63027. */
  63028. depthOfFieldDistance: number;
  63029. /**
  63030. * Represents the blur intensity for the blurred part of the depth of field effect
  63031. */
  63032. depthOfFieldBlurWidth: number;
  63033. /**
  63034. * Gets how much the image is blurred by the movement while using the motion blur post-process
  63035. */
  63036. /**
  63037. * Sets how much the image is blurred by the movement while using the motion blur post-process
  63038. */
  63039. motionStrength: number;
  63040. /**
  63041. * Gets wether or not the motion blur post-process is object based or screen based.
  63042. */
  63043. /**
  63044. * Sets wether or not the motion blur post-process should be object based or screen based
  63045. */
  63046. objectBasedMotionBlur: boolean;
  63047. /**
  63048. * List of animations for the pipeline (IAnimatable implementation)
  63049. */
  63050. animations: Animation[];
  63051. /**
  63052. * Private members
  63053. */
  63054. private _scene;
  63055. private _currentDepthOfFieldSource;
  63056. private _basePostProcess;
  63057. private _fixedExposure;
  63058. private _currentExposure;
  63059. private _hdrAutoExposure;
  63060. private _hdrCurrentLuminance;
  63061. private _motionStrength;
  63062. private _isObjectBasedMotionBlur;
  63063. private _floatTextureType;
  63064. private _camerasToBeAttached;
  63065. private _ratio;
  63066. private _bloomEnabled;
  63067. private _depthOfFieldEnabled;
  63068. private _vlsEnabled;
  63069. private _lensFlareEnabled;
  63070. private _hdrEnabled;
  63071. private _motionBlurEnabled;
  63072. private _fxaaEnabled;
  63073. private _motionBlurSamples;
  63074. private _volumetricLightStepsCount;
  63075. private _samples;
  63076. /**
  63077. * @ignore
  63078. * Specifies if the bloom pipeline is enabled
  63079. */
  63080. BloomEnabled: boolean;
  63081. /**
  63082. * @ignore
  63083. * Specifies if the depth of field pipeline is enabed
  63084. */
  63085. DepthOfFieldEnabled: boolean;
  63086. /**
  63087. * @ignore
  63088. * Specifies if the lens flare pipeline is enabed
  63089. */
  63090. LensFlareEnabled: boolean;
  63091. /**
  63092. * @ignore
  63093. * Specifies if the HDR pipeline is enabled
  63094. */
  63095. HDREnabled: boolean;
  63096. /**
  63097. * @ignore
  63098. * Specifies if the volumetric lights scattering effect is enabled
  63099. */
  63100. VLSEnabled: boolean;
  63101. /**
  63102. * @ignore
  63103. * Specifies if the motion blur effect is enabled
  63104. */
  63105. MotionBlurEnabled: boolean;
  63106. /**
  63107. * Specifies if anti-aliasing is enabled
  63108. */
  63109. fxaaEnabled: boolean;
  63110. /**
  63111. * Specifies the number of steps used to calculate the volumetric lights
  63112. * Typically in interval [50, 200]
  63113. */
  63114. volumetricLightStepsCount: number;
  63115. /**
  63116. * Specifies the number of samples used for the motion blur effect
  63117. * Typically in interval [16, 64]
  63118. */
  63119. motionBlurSamples: number;
  63120. /**
  63121. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63122. */
  63123. samples: number;
  63124. /**
  63125. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63126. * @constructor
  63127. * @param name The rendering pipeline name
  63128. * @param scene The scene linked to this pipeline
  63129. * @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)
  63130. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  63131. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63132. */
  63133. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  63134. private _buildPipeline;
  63135. private _createDownSampleX4PostProcess;
  63136. private _createBrightPassPostProcess;
  63137. private _createBlurPostProcesses;
  63138. private _createTextureAdderPostProcess;
  63139. private _createVolumetricLightPostProcess;
  63140. private _createLuminancePostProcesses;
  63141. private _createHdrPostProcess;
  63142. private _createLensFlarePostProcess;
  63143. private _createDepthOfFieldPostProcess;
  63144. private _createMotionBlurPostProcess;
  63145. private _getDepthTexture;
  63146. private _disposePostProcesses;
  63147. /**
  63148. * Dispose of the pipeline and stop all post processes
  63149. */
  63150. dispose(): void;
  63151. /**
  63152. * Serialize the rendering pipeline (Used when exporting)
  63153. * @returns the serialized object
  63154. */
  63155. serialize(): any;
  63156. /**
  63157. * Parse the serialized pipeline
  63158. * @param source Source pipeline.
  63159. * @param scene The scene to load the pipeline to.
  63160. * @param rootUrl The URL of the serialized pipeline.
  63161. * @returns An instantiated pipeline from the serialized object.
  63162. */
  63163. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  63164. /**
  63165. * Luminance steps
  63166. */
  63167. static LuminanceSteps: number;
  63168. }
  63169. }
  63170. declare module BABYLON {
  63171. /** @hidden */
  63172. export var tonemapPixelShader: {
  63173. name: string;
  63174. shader: string;
  63175. };
  63176. }
  63177. declare module BABYLON {
  63178. /** Defines operator used for tonemapping */
  63179. export enum TonemappingOperator {
  63180. /** Hable */
  63181. Hable = 0,
  63182. /** Reinhard */
  63183. Reinhard = 1,
  63184. /** HejiDawson */
  63185. HejiDawson = 2,
  63186. /** Photographic */
  63187. Photographic = 3
  63188. }
  63189. /**
  63190. * Defines a post process to apply tone mapping
  63191. */
  63192. export class TonemapPostProcess extends PostProcess {
  63193. private _operator;
  63194. /** Defines the required exposure adjustement */
  63195. exposureAdjustment: number;
  63196. /**
  63197. * Creates a new TonemapPostProcess
  63198. * @param name defines the name of the postprocess
  63199. * @param _operator defines the operator to use
  63200. * @param exposureAdjustment defines the required exposure adjustement
  63201. * @param camera defines the camera to use (can be null)
  63202. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  63203. * @param engine defines the hosting engine (can be ignore if camera is set)
  63204. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63205. */
  63206. constructor(name: string, _operator: TonemappingOperator,
  63207. /** Defines the required exposure adjustement */
  63208. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  63209. }
  63210. }
  63211. declare module BABYLON {
  63212. /** @hidden */
  63213. export var depthVertexShader: {
  63214. name: string;
  63215. shader: string;
  63216. };
  63217. }
  63218. declare module BABYLON {
  63219. /** @hidden */
  63220. export var volumetricLightScatteringPixelShader: {
  63221. name: string;
  63222. shader: string;
  63223. };
  63224. }
  63225. declare module BABYLON {
  63226. /** @hidden */
  63227. export var volumetricLightScatteringPassVertexShader: {
  63228. name: string;
  63229. shader: string;
  63230. };
  63231. }
  63232. declare module BABYLON {
  63233. /** @hidden */
  63234. export var volumetricLightScatteringPassPixelShader: {
  63235. name: string;
  63236. shader: string;
  63237. };
  63238. }
  63239. declare module BABYLON {
  63240. /**
  63241. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  63242. */
  63243. export class VolumetricLightScatteringPostProcess extends PostProcess {
  63244. private _volumetricLightScatteringPass;
  63245. private _volumetricLightScatteringRTT;
  63246. private _viewPort;
  63247. private _screenCoordinates;
  63248. private _cachedDefines;
  63249. /**
  63250. * If not undefined, the mesh position is computed from the attached node position
  63251. */
  63252. attachedNode: {
  63253. position: Vector3;
  63254. };
  63255. /**
  63256. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  63257. */
  63258. customMeshPosition: Vector3;
  63259. /**
  63260. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  63261. */
  63262. useCustomMeshPosition: boolean;
  63263. /**
  63264. * If the post-process should inverse the light scattering direction
  63265. */
  63266. invert: boolean;
  63267. /**
  63268. * The internal mesh used by the post-process
  63269. */
  63270. mesh: Mesh;
  63271. /**
  63272. * @hidden
  63273. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  63274. */
  63275. useDiffuseColor: boolean;
  63276. /**
  63277. * Array containing the excluded meshes not rendered in the internal pass
  63278. */
  63279. excludedMeshes: AbstractMesh[];
  63280. /**
  63281. * Controls the overall intensity of the post-process
  63282. */
  63283. exposure: number;
  63284. /**
  63285. * Dissipates each sample's contribution in range [0, 1]
  63286. */
  63287. decay: number;
  63288. /**
  63289. * Controls the overall intensity of each sample
  63290. */
  63291. weight: number;
  63292. /**
  63293. * Controls the density of each sample
  63294. */
  63295. density: number;
  63296. /**
  63297. * @constructor
  63298. * @param name The post-process name
  63299. * @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)
  63300. * @param camera The camera that the post-process will be attached to
  63301. * @param mesh The mesh used to create the light scattering
  63302. * @param samples The post-process quality, default 100
  63303. * @param samplingModeThe post-process filtering mode
  63304. * @param engine The babylon engine
  63305. * @param reusable If the post-process is reusable
  63306. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  63307. */
  63308. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  63309. /**
  63310. * Returns the string "VolumetricLightScatteringPostProcess"
  63311. * @returns "VolumetricLightScatteringPostProcess"
  63312. */
  63313. getClassName(): string;
  63314. private _isReady;
  63315. /**
  63316. * Sets the new light position for light scattering effect
  63317. * @param position The new custom light position
  63318. */
  63319. setCustomMeshPosition(position: Vector3): void;
  63320. /**
  63321. * Returns the light position for light scattering effect
  63322. * @return Vector3 The custom light position
  63323. */
  63324. getCustomMeshPosition(): Vector3;
  63325. /**
  63326. * Disposes the internal assets and detaches the post-process from the camera
  63327. */
  63328. dispose(camera: Camera): void;
  63329. /**
  63330. * Returns the render target texture used by the post-process
  63331. * @return the render target texture used by the post-process
  63332. */
  63333. getPass(): RenderTargetTexture;
  63334. private _meshExcluded;
  63335. private _createPass;
  63336. private _updateMeshScreenCoordinates;
  63337. /**
  63338. * Creates a default mesh for the Volumeric Light Scattering post-process
  63339. * @param name The mesh name
  63340. * @param scene The scene where to create the mesh
  63341. * @return the default mesh
  63342. */
  63343. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  63344. }
  63345. }
  63346. declare module BABYLON {
  63347. interface Scene {
  63348. /** @hidden (Backing field) */
  63349. _boundingBoxRenderer: BoundingBoxRenderer;
  63350. /** @hidden (Backing field) */
  63351. _forceShowBoundingBoxes: boolean;
  63352. /**
  63353. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  63354. */
  63355. forceShowBoundingBoxes: boolean;
  63356. /**
  63357. * Gets the bounding box renderer associated with the scene
  63358. * @returns a BoundingBoxRenderer
  63359. */
  63360. getBoundingBoxRenderer(): BoundingBoxRenderer;
  63361. }
  63362. interface AbstractMesh {
  63363. /** @hidden (Backing field) */
  63364. _showBoundingBox: boolean;
  63365. /**
  63366. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  63367. */
  63368. showBoundingBox: boolean;
  63369. }
  63370. /**
  63371. * Component responsible of rendering the bounding box of the meshes in a scene.
  63372. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  63373. */
  63374. export class BoundingBoxRenderer implements ISceneComponent {
  63375. /**
  63376. * The component name helpfull to identify the component in the list of scene components.
  63377. */
  63378. readonly name: string;
  63379. /**
  63380. * The scene the component belongs to.
  63381. */
  63382. scene: Scene;
  63383. /**
  63384. * Color of the bounding box lines placed in front of an object
  63385. */
  63386. frontColor: Color3;
  63387. /**
  63388. * Color of the bounding box lines placed behind an object
  63389. */
  63390. backColor: Color3;
  63391. /**
  63392. * Defines if the renderer should show the back lines or not
  63393. */
  63394. showBackLines: boolean;
  63395. /**
  63396. * @hidden
  63397. */
  63398. renderList: SmartArray<BoundingBox>;
  63399. private _colorShader;
  63400. private _vertexBuffers;
  63401. private _indexBuffer;
  63402. private _fillIndexBuffer;
  63403. private _fillIndexData;
  63404. /**
  63405. * Instantiates a new bounding box renderer in a scene.
  63406. * @param scene the scene the renderer renders in
  63407. */
  63408. constructor(scene: Scene);
  63409. /**
  63410. * Registers the component in a given scene
  63411. */
  63412. register(): void;
  63413. private _evaluateSubMesh;
  63414. private _activeMesh;
  63415. private _prepareRessources;
  63416. private _createIndexBuffer;
  63417. /**
  63418. * Rebuilds the elements related to this component in case of
  63419. * context lost for instance.
  63420. */
  63421. rebuild(): void;
  63422. /**
  63423. * @hidden
  63424. */
  63425. reset(): void;
  63426. /**
  63427. * Render the bounding boxes of a specific rendering group
  63428. * @param renderingGroupId defines the rendering group to render
  63429. */
  63430. render(renderingGroupId: number): void;
  63431. /**
  63432. * In case of occlusion queries, we can render the occlusion bounding box through this method
  63433. * @param mesh Define the mesh to render the occlusion bounding box for
  63434. */
  63435. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  63436. /**
  63437. * Dispose and release the resources attached to this renderer.
  63438. */
  63439. dispose(): void;
  63440. }
  63441. }
  63442. declare module BABYLON {
  63443. /** @hidden */
  63444. export var depthPixelShader: {
  63445. name: string;
  63446. shader: string;
  63447. };
  63448. }
  63449. declare module BABYLON {
  63450. /**
  63451. * This represents a depth renderer in Babylon.
  63452. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63453. */
  63454. export class DepthRenderer {
  63455. private _scene;
  63456. private _depthMap;
  63457. private _effect;
  63458. private readonly _storeNonLinearDepth;
  63459. private readonly _clearColor;
  63460. /** Get if the depth renderer is using packed depth or not */
  63461. readonly isPacked: boolean;
  63462. private _cachedDefines;
  63463. private _camera;
  63464. /**
  63465. * Specifiess that the depth renderer will only be used within
  63466. * the camera it is created for.
  63467. * This can help forcing its rendering during the camera processing.
  63468. */
  63469. useOnlyInActiveCamera: boolean;
  63470. /** @hidden */
  63471. static _SceneComponentInitialization: (scene: Scene) => void;
  63472. /**
  63473. * Instantiates a depth renderer
  63474. * @param scene The scene the renderer belongs to
  63475. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63476. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63477. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63478. */
  63479. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63480. /**
  63481. * Creates the depth rendering effect and checks if the effect is ready.
  63482. * @param subMesh The submesh to be used to render the depth map of
  63483. * @param useInstances If multiple world instances should be used
  63484. * @returns if the depth renderer is ready to render the depth map
  63485. */
  63486. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63487. /**
  63488. * Gets the texture which the depth map will be written to.
  63489. * @returns The depth map texture
  63490. */
  63491. getDepthMap(): RenderTargetTexture;
  63492. /**
  63493. * Disposes of the depth renderer.
  63494. */
  63495. dispose(): void;
  63496. }
  63497. }
  63498. declare module BABYLON {
  63499. interface Scene {
  63500. /** @hidden (Backing field) */
  63501. _depthRenderer: {
  63502. [id: string]: DepthRenderer;
  63503. };
  63504. /**
  63505. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  63506. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  63507. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63508. * @returns the created depth renderer
  63509. */
  63510. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  63511. /**
  63512. * Disables a depth renderer for a given camera
  63513. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  63514. */
  63515. disableDepthRenderer(camera?: Nullable<Camera>): void;
  63516. }
  63517. /**
  63518. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  63519. * in several rendering techniques.
  63520. */
  63521. export class DepthRendererSceneComponent implements ISceneComponent {
  63522. /**
  63523. * The component name helpfull to identify the component in the list of scene components.
  63524. */
  63525. readonly name: string;
  63526. /**
  63527. * The scene the component belongs to.
  63528. */
  63529. scene: Scene;
  63530. /**
  63531. * Creates a new instance of the component for the given scene
  63532. * @param scene Defines the scene to register the component in
  63533. */
  63534. constructor(scene: Scene);
  63535. /**
  63536. * Registers the component in a given scene
  63537. */
  63538. register(): void;
  63539. /**
  63540. * Rebuilds the elements related to this component in case of
  63541. * context lost for instance.
  63542. */
  63543. rebuild(): void;
  63544. /**
  63545. * Disposes the component and the associated ressources
  63546. */
  63547. dispose(): void;
  63548. private _gatherRenderTargets;
  63549. private _gatherActiveCameraRenderTargets;
  63550. }
  63551. }
  63552. declare module BABYLON {
  63553. /** @hidden */
  63554. export var outlinePixelShader: {
  63555. name: string;
  63556. shader: string;
  63557. };
  63558. }
  63559. declare module BABYLON {
  63560. /** @hidden */
  63561. export var outlineVertexShader: {
  63562. name: string;
  63563. shader: string;
  63564. };
  63565. }
  63566. declare module BABYLON {
  63567. interface Scene {
  63568. /** @hidden */
  63569. _outlineRenderer: OutlineRenderer;
  63570. /**
  63571. * Gets the outline renderer associated with the scene
  63572. * @returns a OutlineRenderer
  63573. */
  63574. getOutlineRenderer(): OutlineRenderer;
  63575. }
  63576. interface AbstractMesh {
  63577. /** @hidden (Backing field) */
  63578. _renderOutline: boolean;
  63579. /**
  63580. * Gets or sets a boolean indicating if the outline must be rendered as well
  63581. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  63582. */
  63583. renderOutline: boolean;
  63584. /** @hidden (Backing field) */
  63585. _renderOverlay: boolean;
  63586. /**
  63587. * Gets or sets a boolean indicating if the overlay must be rendered as well
  63588. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  63589. */
  63590. renderOverlay: boolean;
  63591. }
  63592. /**
  63593. * This class is responsible to draw bothe outline/overlay of meshes.
  63594. * It should not be used directly but through the available method on mesh.
  63595. */
  63596. export class OutlineRenderer implements ISceneComponent {
  63597. /**
  63598. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  63599. */
  63600. private static _StencilReference;
  63601. /**
  63602. * The name of the component. Each component must have a unique name.
  63603. */
  63604. name: string;
  63605. /**
  63606. * The scene the component belongs to.
  63607. */
  63608. scene: Scene;
  63609. /**
  63610. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  63611. */
  63612. zOffset: number;
  63613. private _engine;
  63614. private _effect;
  63615. private _cachedDefines;
  63616. private _savedDepthWrite;
  63617. /**
  63618. * Instantiates a new outline renderer. (There could be only one per scene).
  63619. * @param scene Defines the scene it belongs to
  63620. */
  63621. constructor(scene: Scene);
  63622. /**
  63623. * Register the component to one instance of a scene.
  63624. */
  63625. register(): void;
  63626. /**
  63627. * Rebuilds the elements related to this component in case of
  63628. * context lost for instance.
  63629. */
  63630. rebuild(): void;
  63631. /**
  63632. * Disposes the component and the associated ressources.
  63633. */
  63634. dispose(): void;
  63635. /**
  63636. * Renders the outline in the canvas.
  63637. * @param subMesh Defines the sumesh to render
  63638. * @param batch Defines the batch of meshes in case of instances
  63639. * @param useOverlay Defines if the rendering is for the overlay or the outline
  63640. */
  63641. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  63642. /**
  63643. * Returns whether or not the outline renderer is ready for a given submesh.
  63644. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  63645. * @param subMesh Defines the submesh to check readyness for
  63646. * @param useInstances Defines wheter wee are trying to render instances or not
  63647. * @returns true if ready otherwise false
  63648. */
  63649. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63650. private _beforeRenderingMesh;
  63651. private _afterRenderingMesh;
  63652. }
  63653. }
  63654. declare module BABYLON {
  63655. /**
  63656. * Defines the basic options interface of a Sprite Frame Source Size.
  63657. */
  63658. export interface ISpriteJSONSpriteSourceSize {
  63659. /**
  63660. * number of the original width of the Frame
  63661. */
  63662. w: number;
  63663. /**
  63664. * number of the original height of the Frame
  63665. */
  63666. h: number;
  63667. }
  63668. /**
  63669. * Defines the basic options interface of a Sprite Frame Data.
  63670. */
  63671. export interface ISpriteJSONSpriteFrameData {
  63672. /**
  63673. * number of the x offset of the Frame
  63674. */
  63675. x: number;
  63676. /**
  63677. * number of the y offset of the Frame
  63678. */
  63679. y: number;
  63680. /**
  63681. * number of the width of the Frame
  63682. */
  63683. w: number;
  63684. /**
  63685. * number of the height of the Frame
  63686. */
  63687. h: number;
  63688. }
  63689. /**
  63690. * Defines the basic options interface of a JSON Sprite.
  63691. */
  63692. export interface ISpriteJSONSprite {
  63693. /**
  63694. * string name of the Frame
  63695. */
  63696. filename: string;
  63697. /**
  63698. * ISpriteJSONSpriteFrame basic object of the frame data
  63699. */
  63700. frame: ISpriteJSONSpriteFrameData;
  63701. /**
  63702. * boolean to flag is the frame was rotated.
  63703. */
  63704. rotated: boolean;
  63705. /**
  63706. * boolean to flag is the frame was trimmed.
  63707. */
  63708. trimmed: boolean;
  63709. /**
  63710. * ISpriteJSONSpriteFrame basic object of the source data
  63711. */
  63712. spriteSourceSize: ISpriteJSONSpriteFrameData;
  63713. /**
  63714. * ISpriteJSONSpriteFrame basic object of the source data
  63715. */
  63716. sourceSize: ISpriteJSONSpriteSourceSize;
  63717. }
  63718. /**
  63719. * Defines the basic options interface of a JSON atlas.
  63720. */
  63721. export interface ISpriteJSONAtlas {
  63722. /**
  63723. * Array of objects that contain the frame data.
  63724. */
  63725. frames: Array<ISpriteJSONSprite>;
  63726. /**
  63727. * object basic object containing the sprite meta data.
  63728. */
  63729. meta?: object;
  63730. }
  63731. }
  63732. declare module BABYLON {
  63733. /** @hidden */
  63734. export var spriteMapPixelShader: {
  63735. name: string;
  63736. shader: string;
  63737. };
  63738. }
  63739. declare module BABYLON {
  63740. /** @hidden */
  63741. export var spriteMapVertexShader: {
  63742. name: string;
  63743. shader: string;
  63744. };
  63745. }
  63746. declare module BABYLON {
  63747. /**
  63748. * Defines the basic options interface of a SpriteMap
  63749. */
  63750. export interface ISpriteMapOptions {
  63751. /**
  63752. * Vector2 of the number of cells in the grid.
  63753. */
  63754. stageSize?: Vector2;
  63755. /**
  63756. * Vector2 of the size of the output plane in World Units.
  63757. */
  63758. outputSize?: Vector2;
  63759. /**
  63760. * Vector3 of the position of the output plane in World Units.
  63761. */
  63762. outputPosition?: Vector3;
  63763. /**
  63764. * Vector3 of the rotation of the output plane.
  63765. */
  63766. outputRotation?: Vector3;
  63767. /**
  63768. * number of layers that the system will reserve in resources.
  63769. */
  63770. layerCount?: number;
  63771. /**
  63772. * number of max animation frames a single cell will reserve in resources.
  63773. */
  63774. maxAnimationFrames?: number;
  63775. /**
  63776. * number cell index of the base tile when the system compiles.
  63777. */
  63778. baseTile?: number;
  63779. /**
  63780. * boolean flip the sprite after its been repositioned by the framing data.
  63781. */
  63782. flipU?: boolean;
  63783. /**
  63784. * Vector3 scalar of the global RGB values of the SpriteMap.
  63785. */
  63786. colorMultiply?: Vector3;
  63787. }
  63788. /**
  63789. * Defines the IDisposable interface in order to be cleanable from resources.
  63790. */
  63791. export interface ISpriteMap extends IDisposable {
  63792. /**
  63793. * String name of the SpriteMap.
  63794. */
  63795. name: string;
  63796. /**
  63797. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  63798. */
  63799. atlasJSON: ISpriteJSONAtlas;
  63800. /**
  63801. * Texture of the SpriteMap.
  63802. */
  63803. spriteSheet: Texture;
  63804. /**
  63805. * The parameters to initialize the SpriteMap with.
  63806. */
  63807. options: ISpriteMapOptions;
  63808. }
  63809. /**
  63810. * Class used to manage a grid restricted sprite deployment on an Output plane.
  63811. */
  63812. export class SpriteMap implements ISpriteMap {
  63813. /** The Name of the spriteMap */
  63814. name: string;
  63815. /** The JSON file with the frame and meta data */
  63816. atlasJSON: ISpriteJSONAtlas;
  63817. /** The systems Sprite Sheet Texture */
  63818. spriteSheet: Texture;
  63819. /** Arguments passed with the Constructor */
  63820. options: ISpriteMapOptions;
  63821. /** Public Sprite Storage array, parsed from atlasJSON */
  63822. sprites: Array<ISpriteJSONSprite>;
  63823. /** Returns the Number of Sprites in the System */
  63824. readonly spriteCount: number;
  63825. /** Returns the Position of Output Plane*/
  63826. /** Returns the Position of Output Plane*/
  63827. position: Vector3;
  63828. /** Returns the Rotation of Output Plane*/
  63829. /** Returns the Rotation of Output Plane*/
  63830. rotation: Vector3;
  63831. /** Sets the AnimationMap*/
  63832. /** Sets the AnimationMap*/
  63833. animationMap: RawTexture;
  63834. /** Scene that the SpriteMap was created in */
  63835. private _scene;
  63836. /** Texture Buffer of Float32 that holds tile frame data*/
  63837. private _frameMap;
  63838. /** Texture Buffers of Float32 that holds tileMap data*/
  63839. private _tileMaps;
  63840. /** Texture Buffer of Float32 that holds Animation Data*/
  63841. private _animationMap;
  63842. /** Custom ShaderMaterial Central to the System*/
  63843. private _material;
  63844. /** Custom ShaderMaterial Central to the System*/
  63845. private _output;
  63846. /** Systems Time Ticker*/
  63847. private _time;
  63848. /**
  63849. * Creates a new SpriteMap
  63850. * @param name defines the SpriteMaps Name
  63851. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  63852. * @param spriteSheet is the Texture that the Sprites are on.
  63853. * @param options a basic deployment configuration
  63854. * @param scene The Scene that the map is deployed on
  63855. */
  63856. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  63857. /**
  63858. * Returns tileID location
  63859. * @returns Vector2 the cell position ID
  63860. */
  63861. getTileID(): Vector2;
  63862. /**
  63863. * Gets the UV location of the mouse over the SpriteMap.
  63864. * @returns Vector2 the UV position of the mouse interaction
  63865. */
  63866. getMousePosition(): Vector2;
  63867. /**
  63868. * Creates the "frame" texture Buffer
  63869. * -------------------------------------
  63870. * Structure of frames
  63871. * "filename": "Falling-Water-2.png",
  63872. * "frame": {"x":69,"y":103,"w":24,"h":32},
  63873. * "rotated": true,
  63874. * "trimmed": true,
  63875. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  63876. * "sourceSize": {"w":32,"h":32}
  63877. * @returns RawTexture of the frameMap
  63878. */
  63879. private _createFrameBuffer;
  63880. /**
  63881. * Creates the tileMap texture Buffer
  63882. * @param buffer normally and array of numbers, or a false to generate from scratch
  63883. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  63884. * @returns RawTexture of the tileMap
  63885. */
  63886. private _createTileBuffer;
  63887. /**
  63888. * Modifies the data of the tileMaps
  63889. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  63890. * @param pos is the iVector2 Coordinates of the Tile
  63891. * @param tile The SpriteIndex of the new Tile
  63892. */
  63893. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  63894. /**
  63895. * Creates the animationMap texture Buffer
  63896. * @param buffer normally and array of numbers, or a false to generate from scratch
  63897. * @returns RawTexture of the animationMap
  63898. */
  63899. private _createTileAnimationBuffer;
  63900. /**
  63901. * Modifies the data of the animationMap
  63902. * @param cellID is the Index of the Sprite
  63903. * @param _frame is the target Animation frame
  63904. * @param toCell is the Target Index of the next frame of the animation
  63905. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  63906. * @param speed is a global scalar of the time variable on the map.
  63907. */
  63908. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  63909. /**
  63910. * Exports the .tilemaps file
  63911. */
  63912. saveTileMaps(): void;
  63913. /**
  63914. * Imports the .tilemaps file
  63915. * @param url of the .tilemaps file
  63916. */
  63917. loadTileMaps(url: string): void;
  63918. /**
  63919. * Release associated resources
  63920. */
  63921. dispose(): void;
  63922. }
  63923. }
  63924. declare module BABYLON {
  63925. /**
  63926. * Class used to manage multiple sprites of different sizes on the same spritesheet
  63927. * @see http://doc.babylonjs.com/babylon101/sprites
  63928. */
  63929. export class SpritePackedManager extends SpriteManager {
  63930. /** defines the packed manager's name */
  63931. name: string;
  63932. /**
  63933. * Creates a new sprite manager from a packed sprite sheet
  63934. * @param name defines the manager's name
  63935. * @param imgUrl defines the sprite sheet url
  63936. * @param capacity defines the maximum allowed number of sprites
  63937. * @param scene defines the hosting scene
  63938. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  63939. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  63940. * @param samplingMode defines the smapling mode to use with spritesheet
  63941. * @param fromPacked set to true; do not alter
  63942. */
  63943. constructor(
  63944. /** defines the packed manager's name */
  63945. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  63946. }
  63947. }
  63948. declare module BABYLON {
  63949. /**
  63950. * Defines the list of states available for a task inside a AssetsManager
  63951. */
  63952. export enum AssetTaskState {
  63953. /**
  63954. * Initialization
  63955. */
  63956. INIT = 0,
  63957. /**
  63958. * Running
  63959. */
  63960. RUNNING = 1,
  63961. /**
  63962. * Done
  63963. */
  63964. DONE = 2,
  63965. /**
  63966. * Error
  63967. */
  63968. ERROR = 3
  63969. }
  63970. /**
  63971. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  63972. */
  63973. export abstract class AbstractAssetTask {
  63974. /**
  63975. * Task name
  63976. */ name: string;
  63977. /**
  63978. * Callback called when the task is successful
  63979. */
  63980. onSuccess: (task: any) => void;
  63981. /**
  63982. * Callback called when the task is not successful
  63983. */
  63984. onError: (task: any, message?: string, exception?: any) => void;
  63985. /**
  63986. * Creates a new AssetsManager
  63987. * @param name defines the name of the task
  63988. */
  63989. constructor(
  63990. /**
  63991. * Task name
  63992. */ name: string);
  63993. private _isCompleted;
  63994. private _taskState;
  63995. private _errorObject;
  63996. /**
  63997. * Get if the task is completed
  63998. */
  63999. readonly isCompleted: boolean;
  64000. /**
  64001. * Gets the current state of the task
  64002. */
  64003. readonly taskState: AssetTaskState;
  64004. /**
  64005. * Gets the current error object (if task is in error)
  64006. */
  64007. readonly errorObject: {
  64008. message?: string;
  64009. exception?: any;
  64010. };
  64011. /**
  64012. * Internal only
  64013. * @hidden
  64014. */
  64015. _setErrorObject(message?: string, exception?: any): void;
  64016. /**
  64017. * Execute the current task
  64018. * @param scene defines the scene where you want your assets to be loaded
  64019. * @param onSuccess is a callback called when the task is successfully executed
  64020. * @param onError is a callback called if an error occurs
  64021. */
  64022. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64023. /**
  64024. * Execute the current task
  64025. * @param scene defines the scene where you want your assets to be loaded
  64026. * @param onSuccess is a callback called when the task is successfully executed
  64027. * @param onError is a callback called if an error occurs
  64028. */
  64029. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64030. /**
  64031. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  64032. * This can be used with failed tasks that have the reason for failure fixed.
  64033. */
  64034. reset(): void;
  64035. private onErrorCallback;
  64036. private onDoneCallback;
  64037. }
  64038. /**
  64039. * Define the interface used by progress events raised during assets loading
  64040. */
  64041. export interface IAssetsProgressEvent {
  64042. /**
  64043. * Defines the number of remaining tasks to process
  64044. */
  64045. remainingCount: number;
  64046. /**
  64047. * Defines the total number of tasks
  64048. */
  64049. totalCount: number;
  64050. /**
  64051. * Defines the task that was just processed
  64052. */
  64053. task: AbstractAssetTask;
  64054. }
  64055. /**
  64056. * Class used to share progress information about assets loading
  64057. */
  64058. export class AssetsProgressEvent implements IAssetsProgressEvent {
  64059. /**
  64060. * Defines the number of remaining tasks to process
  64061. */
  64062. remainingCount: number;
  64063. /**
  64064. * Defines the total number of tasks
  64065. */
  64066. totalCount: number;
  64067. /**
  64068. * Defines the task that was just processed
  64069. */
  64070. task: AbstractAssetTask;
  64071. /**
  64072. * Creates a AssetsProgressEvent
  64073. * @param remainingCount defines the number of remaining tasks to process
  64074. * @param totalCount defines the total number of tasks
  64075. * @param task defines the task that was just processed
  64076. */
  64077. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  64078. }
  64079. /**
  64080. * Define a task used by AssetsManager to load meshes
  64081. */
  64082. export class MeshAssetTask extends AbstractAssetTask {
  64083. /**
  64084. * Defines the name of the task
  64085. */
  64086. name: string;
  64087. /**
  64088. * Defines the list of mesh's names you want to load
  64089. */
  64090. meshesNames: any;
  64091. /**
  64092. * Defines the root url to use as a base to load your meshes and associated resources
  64093. */
  64094. rootUrl: string;
  64095. /**
  64096. * Defines the filename of the scene to load from
  64097. */
  64098. sceneFilename: string;
  64099. /**
  64100. * Gets the list of loaded meshes
  64101. */
  64102. loadedMeshes: Array<AbstractMesh>;
  64103. /**
  64104. * Gets the list of loaded particle systems
  64105. */
  64106. loadedParticleSystems: Array<IParticleSystem>;
  64107. /**
  64108. * Gets the list of loaded skeletons
  64109. */
  64110. loadedSkeletons: Array<Skeleton>;
  64111. /**
  64112. * Gets the list of loaded animation groups
  64113. */
  64114. loadedAnimationGroups: Array<AnimationGroup>;
  64115. /**
  64116. * Callback called when the task is successful
  64117. */
  64118. onSuccess: (task: MeshAssetTask) => void;
  64119. /**
  64120. * Callback called when the task is successful
  64121. */
  64122. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  64123. /**
  64124. * Creates a new MeshAssetTask
  64125. * @param name defines the name of the task
  64126. * @param meshesNames defines the list of mesh's names you want to load
  64127. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  64128. * @param sceneFilename defines the filename of the scene to load from
  64129. */
  64130. constructor(
  64131. /**
  64132. * Defines the name of the task
  64133. */
  64134. name: string,
  64135. /**
  64136. * Defines the list of mesh's names you want to load
  64137. */
  64138. meshesNames: any,
  64139. /**
  64140. * Defines the root url to use as a base to load your meshes and associated resources
  64141. */
  64142. rootUrl: string,
  64143. /**
  64144. * Defines the filename of the scene to load from
  64145. */
  64146. sceneFilename: string);
  64147. /**
  64148. * Execute the current task
  64149. * @param scene defines the scene where you want your assets to be loaded
  64150. * @param onSuccess is a callback called when the task is successfully executed
  64151. * @param onError is a callback called if an error occurs
  64152. */
  64153. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64154. }
  64155. /**
  64156. * Define a task used by AssetsManager to load text content
  64157. */
  64158. export class TextFileAssetTask extends AbstractAssetTask {
  64159. /**
  64160. * Defines the name of the task
  64161. */
  64162. name: string;
  64163. /**
  64164. * Defines the location of the file to load
  64165. */
  64166. url: string;
  64167. /**
  64168. * Gets the loaded text string
  64169. */
  64170. text: string;
  64171. /**
  64172. * Callback called when the task is successful
  64173. */
  64174. onSuccess: (task: TextFileAssetTask) => void;
  64175. /**
  64176. * Callback called when the task is successful
  64177. */
  64178. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  64179. /**
  64180. * Creates a new TextFileAssetTask object
  64181. * @param name defines the name of the task
  64182. * @param url defines the location of the file to load
  64183. */
  64184. constructor(
  64185. /**
  64186. * Defines the name of the task
  64187. */
  64188. name: string,
  64189. /**
  64190. * Defines the location of the file to load
  64191. */
  64192. url: string);
  64193. /**
  64194. * Execute the current task
  64195. * @param scene defines the scene where you want your assets to be loaded
  64196. * @param onSuccess is a callback called when the task is successfully executed
  64197. * @param onError is a callback called if an error occurs
  64198. */
  64199. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64200. }
  64201. /**
  64202. * Define a task used by AssetsManager to load binary data
  64203. */
  64204. export class BinaryFileAssetTask extends AbstractAssetTask {
  64205. /**
  64206. * Defines the name of the task
  64207. */
  64208. name: string;
  64209. /**
  64210. * Defines the location of the file to load
  64211. */
  64212. url: string;
  64213. /**
  64214. * Gets the lodaded data (as an array buffer)
  64215. */
  64216. data: ArrayBuffer;
  64217. /**
  64218. * Callback called when the task is successful
  64219. */
  64220. onSuccess: (task: BinaryFileAssetTask) => void;
  64221. /**
  64222. * Callback called when the task is successful
  64223. */
  64224. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  64225. /**
  64226. * Creates a new BinaryFileAssetTask object
  64227. * @param name defines the name of the new task
  64228. * @param url defines the location of the file to load
  64229. */
  64230. constructor(
  64231. /**
  64232. * Defines the name of the task
  64233. */
  64234. name: string,
  64235. /**
  64236. * Defines the location of the file to load
  64237. */
  64238. url: string);
  64239. /**
  64240. * Execute the current task
  64241. * @param scene defines the scene where you want your assets to be loaded
  64242. * @param onSuccess is a callback called when the task is successfully executed
  64243. * @param onError is a callback called if an error occurs
  64244. */
  64245. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64246. }
  64247. /**
  64248. * Define a task used by AssetsManager to load images
  64249. */
  64250. export class ImageAssetTask extends AbstractAssetTask {
  64251. /**
  64252. * Defines the name of the task
  64253. */
  64254. name: string;
  64255. /**
  64256. * Defines the location of the image to load
  64257. */
  64258. url: string;
  64259. /**
  64260. * Gets the loaded images
  64261. */
  64262. image: HTMLImageElement;
  64263. /**
  64264. * Callback called when the task is successful
  64265. */
  64266. onSuccess: (task: ImageAssetTask) => void;
  64267. /**
  64268. * Callback called when the task is successful
  64269. */
  64270. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  64271. /**
  64272. * Creates a new ImageAssetTask
  64273. * @param name defines the name of the task
  64274. * @param url defines the location of the image to load
  64275. */
  64276. constructor(
  64277. /**
  64278. * Defines the name of the task
  64279. */
  64280. name: string,
  64281. /**
  64282. * Defines the location of the image to load
  64283. */
  64284. url: string);
  64285. /**
  64286. * Execute the current task
  64287. * @param scene defines the scene where you want your assets to be loaded
  64288. * @param onSuccess is a callback called when the task is successfully executed
  64289. * @param onError is a callback called if an error occurs
  64290. */
  64291. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64292. }
  64293. /**
  64294. * Defines the interface used by texture loading tasks
  64295. */
  64296. export interface ITextureAssetTask<TEX extends BaseTexture> {
  64297. /**
  64298. * Gets the loaded texture
  64299. */
  64300. texture: TEX;
  64301. }
  64302. /**
  64303. * Define a task used by AssetsManager to load 2D textures
  64304. */
  64305. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  64306. /**
  64307. * Defines the name of the task
  64308. */
  64309. name: string;
  64310. /**
  64311. * Defines the location of the file to load
  64312. */
  64313. url: string;
  64314. /**
  64315. * Defines if mipmap should not be generated (default is false)
  64316. */
  64317. noMipmap?: boolean | undefined;
  64318. /**
  64319. * Defines if texture must be inverted on Y axis (default is false)
  64320. */
  64321. invertY?: boolean | undefined;
  64322. /**
  64323. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64324. */
  64325. samplingMode: number;
  64326. /**
  64327. * Gets the loaded texture
  64328. */
  64329. texture: Texture;
  64330. /**
  64331. * Callback called when the task is successful
  64332. */
  64333. onSuccess: (task: TextureAssetTask) => void;
  64334. /**
  64335. * Callback called when the task is successful
  64336. */
  64337. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  64338. /**
  64339. * Creates a new TextureAssetTask object
  64340. * @param name defines the name of the task
  64341. * @param url defines the location of the file to load
  64342. * @param noMipmap defines if mipmap should not be generated (default is false)
  64343. * @param invertY defines if texture must be inverted on Y axis (default is false)
  64344. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64345. */
  64346. constructor(
  64347. /**
  64348. * Defines the name of the task
  64349. */
  64350. name: string,
  64351. /**
  64352. * Defines the location of the file to load
  64353. */
  64354. url: string,
  64355. /**
  64356. * Defines if mipmap should not be generated (default is false)
  64357. */
  64358. noMipmap?: boolean | undefined,
  64359. /**
  64360. * Defines if texture must be inverted on Y axis (default is false)
  64361. */
  64362. invertY?: boolean | undefined,
  64363. /**
  64364. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64365. */
  64366. samplingMode?: number);
  64367. /**
  64368. * Execute the current task
  64369. * @param scene defines the scene where you want your assets to be loaded
  64370. * @param onSuccess is a callback called when the task is successfully executed
  64371. * @param onError is a callback called if an error occurs
  64372. */
  64373. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64374. }
  64375. /**
  64376. * Define a task used by AssetsManager to load cube textures
  64377. */
  64378. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  64379. /**
  64380. * Defines the name of the task
  64381. */
  64382. name: string;
  64383. /**
  64384. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64385. */
  64386. url: string;
  64387. /**
  64388. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64389. */
  64390. extensions?: string[] | undefined;
  64391. /**
  64392. * Defines if mipmaps should not be generated (default is false)
  64393. */
  64394. noMipmap?: boolean | undefined;
  64395. /**
  64396. * Defines the explicit list of files (undefined by default)
  64397. */
  64398. files?: string[] | undefined;
  64399. /**
  64400. * Gets the loaded texture
  64401. */
  64402. texture: CubeTexture;
  64403. /**
  64404. * Callback called when the task is successful
  64405. */
  64406. onSuccess: (task: CubeTextureAssetTask) => void;
  64407. /**
  64408. * Callback called when the task is successful
  64409. */
  64410. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  64411. /**
  64412. * Creates a new CubeTextureAssetTask
  64413. * @param name defines the name of the task
  64414. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64415. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64416. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64417. * @param files defines the explicit list of files (undefined by default)
  64418. */
  64419. constructor(
  64420. /**
  64421. * Defines the name of the task
  64422. */
  64423. name: string,
  64424. /**
  64425. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64426. */
  64427. url: string,
  64428. /**
  64429. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64430. */
  64431. extensions?: string[] | undefined,
  64432. /**
  64433. * Defines if mipmaps should not be generated (default is false)
  64434. */
  64435. noMipmap?: boolean | undefined,
  64436. /**
  64437. * Defines the explicit list of files (undefined by default)
  64438. */
  64439. files?: string[] | undefined);
  64440. /**
  64441. * Execute the current task
  64442. * @param scene defines the scene where you want your assets to be loaded
  64443. * @param onSuccess is a callback called when the task is successfully executed
  64444. * @param onError is a callback called if an error occurs
  64445. */
  64446. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64447. }
  64448. /**
  64449. * Define a task used by AssetsManager to load HDR cube textures
  64450. */
  64451. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  64452. /**
  64453. * Defines the name of the task
  64454. */
  64455. name: string;
  64456. /**
  64457. * Defines the location of the file to load
  64458. */
  64459. url: string;
  64460. /**
  64461. * Defines the desired size (the more it increases the longer the generation will be)
  64462. */
  64463. size: number;
  64464. /**
  64465. * Defines if mipmaps should not be generated (default is false)
  64466. */
  64467. noMipmap: boolean;
  64468. /**
  64469. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64470. */
  64471. generateHarmonics: boolean;
  64472. /**
  64473. * 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)
  64474. */
  64475. gammaSpace: boolean;
  64476. /**
  64477. * Internal Use Only
  64478. */
  64479. reserved: boolean;
  64480. /**
  64481. * Gets the loaded texture
  64482. */
  64483. texture: HDRCubeTexture;
  64484. /**
  64485. * Callback called when the task is successful
  64486. */
  64487. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  64488. /**
  64489. * Callback called when the task is successful
  64490. */
  64491. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  64492. /**
  64493. * Creates a new HDRCubeTextureAssetTask object
  64494. * @param name defines the name of the task
  64495. * @param url defines the location of the file to load
  64496. * @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.
  64497. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64498. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64499. * @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)
  64500. * @param reserved Internal use only
  64501. */
  64502. constructor(
  64503. /**
  64504. * Defines the name of the task
  64505. */
  64506. name: string,
  64507. /**
  64508. * Defines the location of the file to load
  64509. */
  64510. url: string,
  64511. /**
  64512. * Defines the desired size (the more it increases the longer the generation will be)
  64513. */
  64514. size: number,
  64515. /**
  64516. * Defines if mipmaps should not be generated (default is false)
  64517. */
  64518. noMipmap?: boolean,
  64519. /**
  64520. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64521. */
  64522. generateHarmonics?: boolean,
  64523. /**
  64524. * 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)
  64525. */
  64526. gammaSpace?: boolean,
  64527. /**
  64528. * Internal Use Only
  64529. */
  64530. reserved?: boolean);
  64531. /**
  64532. * Execute the current task
  64533. * @param scene defines the scene where you want your assets to be loaded
  64534. * @param onSuccess is a callback called when the task is successfully executed
  64535. * @param onError is a callback called if an error occurs
  64536. */
  64537. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64538. }
  64539. /**
  64540. * Define a task used by AssetsManager to load Equirectangular cube textures
  64541. */
  64542. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  64543. /**
  64544. * Defines the name of the task
  64545. */
  64546. name: string;
  64547. /**
  64548. * Defines the location of the file to load
  64549. */
  64550. url: string;
  64551. /**
  64552. * Defines the desired size (the more it increases the longer the generation will be)
  64553. */
  64554. size: number;
  64555. /**
  64556. * Defines if mipmaps should not be generated (default is false)
  64557. */
  64558. noMipmap: boolean;
  64559. /**
  64560. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64561. * but the standard material would require them in Gamma space) (default is true)
  64562. */
  64563. gammaSpace: boolean;
  64564. /**
  64565. * Gets the loaded texture
  64566. */
  64567. texture: EquiRectangularCubeTexture;
  64568. /**
  64569. * Callback called when the task is successful
  64570. */
  64571. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  64572. /**
  64573. * Callback called when the task is successful
  64574. */
  64575. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  64576. /**
  64577. * Creates a new EquiRectangularCubeTextureAssetTask object
  64578. * @param name defines the name of the task
  64579. * @param url defines the location of the file to load
  64580. * @param size defines the desired size (the more it increases the longer the generation will be)
  64581. * If the size is omitted this implies you are using a preprocessed cubemap.
  64582. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64583. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  64584. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  64585. * (default is true)
  64586. */
  64587. constructor(
  64588. /**
  64589. * Defines the name of the task
  64590. */
  64591. name: string,
  64592. /**
  64593. * Defines the location of the file to load
  64594. */
  64595. url: string,
  64596. /**
  64597. * Defines the desired size (the more it increases the longer the generation will be)
  64598. */
  64599. size: number,
  64600. /**
  64601. * Defines if mipmaps should not be generated (default is false)
  64602. */
  64603. noMipmap?: boolean,
  64604. /**
  64605. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64606. * but the standard material would require them in Gamma space) (default is true)
  64607. */
  64608. gammaSpace?: boolean);
  64609. /**
  64610. * Execute the current task
  64611. * @param scene defines the scene where you want your assets to be loaded
  64612. * @param onSuccess is a callback called when the task is successfully executed
  64613. * @param onError is a callback called if an error occurs
  64614. */
  64615. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64616. }
  64617. /**
  64618. * This class can be used to easily import assets into a scene
  64619. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  64620. */
  64621. export class AssetsManager {
  64622. private _scene;
  64623. private _isLoading;
  64624. protected _tasks: AbstractAssetTask[];
  64625. protected _waitingTasksCount: number;
  64626. protected _totalTasksCount: number;
  64627. /**
  64628. * Callback called when all tasks are processed
  64629. */
  64630. onFinish: (tasks: AbstractAssetTask[]) => void;
  64631. /**
  64632. * Callback called when a task is successful
  64633. */
  64634. onTaskSuccess: (task: AbstractAssetTask) => void;
  64635. /**
  64636. * Callback called when a task had an error
  64637. */
  64638. onTaskError: (task: AbstractAssetTask) => void;
  64639. /**
  64640. * Callback called when a task is done (whatever the result is)
  64641. */
  64642. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  64643. /**
  64644. * Observable called when all tasks are processed
  64645. */
  64646. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  64647. /**
  64648. * Observable called when a task had an error
  64649. */
  64650. onTaskErrorObservable: Observable<AbstractAssetTask>;
  64651. /**
  64652. * Observable called when all tasks were executed
  64653. */
  64654. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  64655. /**
  64656. * Observable called when a task is done (whatever the result is)
  64657. */
  64658. onProgressObservable: Observable<IAssetsProgressEvent>;
  64659. /**
  64660. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  64661. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  64662. */
  64663. useDefaultLoadingScreen: boolean;
  64664. /**
  64665. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  64666. * when all assets have been downloaded.
  64667. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  64668. */
  64669. autoHideLoadingUI: boolean;
  64670. /**
  64671. * Creates a new AssetsManager
  64672. * @param scene defines the scene to work on
  64673. */
  64674. constructor(scene: Scene);
  64675. /**
  64676. * Add a MeshAssetTask to the list of active tasks
  64677. * @param taskName defines the name of the new task
  64678. * @param meshesNames defines the name of meshes to load
  64679. * @param rootUrl defines the root url to use to locate files
  64680. * @param sceneFilename defines the filename of the scene file
  64681. * @returns a new MeshAssetTask object
  64682. */
  64683. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  64684. /**
  64685. * Add a TextFileAssetTask to the list of active tasks
  64686. * @param taskName defines the name of the new task
  64687. * @param url defines the url of the file to load
  64688. * @returns a new TextFileAssetTask object
  64689. */
  64690. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  64691. /**
  64692. * Add a BinaryFileAssetTask to the list of active tasks
  64693. * @param taskName defines the name of the new task
  64694. * @param url defines the url of the file to load
  64695. * @returns a new BinaryFileAssetTask object
  64696. */
  64697. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  64698. /**
  64699. * Add a ImageAssetTask to the list of active tasks
  64700. * @param taskName defines the name of the new task
  64701. * @param url defines the url of the file to load
  64702. * @returns a new ImageAssetTask object
  64703. */
  64704. addImageTask(taskName: string, url: string): ImageAssetTask;
  64705. /**
  64706. * Add a TextureAssetTask to the list of active tasks
  64707. * @param taskName defines the name of the new task
  64708. * @param url defines the url of the file to load
  64709. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64710. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  64711. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64712. * @returns a new TextureAssetTask object
  64713. */
  64714. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  64715. /**
  64716. * Add a CubeTextureAssetTask to the list of active tasks
  64717. * @param taskName defines the name of the new task
  64718. * @param url defines the url of the file to load
  64719. * @param extensions defines the extension to use to load the cube map (can be null)
  64720. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64721. * @param files defines the list of files to load (can be null)
  64722. * @returns a new CubeTextureAssetTask object
  64723. */
  64724. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  64725. /**
  64726. *
  64727. * Add a HDRCubeTextureAssetTask to the list of active tasks
  64728. * @param taskName defines the name of the new task
  64729. * @param url defines the url of the file to load
  64730. * @param size defines the size you want for the cubemap (can be null)
  64731. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64732. * @param generateHarmonics defines if you want to automatically generate (true by default)
  64733. * @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)
  64734. * @param reserved Internal use only
  64735. * @returns a new HDRCubeTextureAssetTask object
  64736. */
  64737. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  64738. /**
  64739. *
  64740. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  64741. * @param taskName defines the name of the new task
  64742. * @param url defines the url of the file to load
  64743. * @param size defines the size you want for the cubemap (can be null)
  64744. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64745. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64746. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64747. * @returns a new EquiRectangularCubeTextureAssetTask object
  64748. */
  64749. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  64750. /**
  64751. * Remove a task from the assets manager.
  64752. * @param task the task to remove
  64753. */
  64754. removeTask(task: AbstractAssetTask): void;
  64755. private _decreaseWaitingTasksCount;
  64756. private _runTask;
  64757. /**
  64758. * Reset the AssetsManager and remove all tasks
  64759. * @return the current instance of the AssetsManager
  64760. */
  64761. reset(): AssetsManager;
  64762. /**
  64763. * Start the loading process
  64764. * @return the current instance of the AssetsManager
  64765. */
  64766. load(): AssetsManager;
  64767. /**
  64768. * Start the loading process as an async operation
  64769. * @return a promise returning the list of failed tasks
  64770. */
  64771. loadAsync(): Promise<void>;
  64772. }
  64773. }
  64774. declare module BABYLON {
  64775. /**
  64776. * Wrapper class for promise with external resolve and reject.
  64777. */
  64778. export class Deferred<T> {
  64779. /**
  64780. * The promise associated with this deferred object.
  64781. */
  64782. readonly promise: Promise<T>;
  64783. private _resolve;
  64784. private _reject;
  64785. /**
  64786. * The resolve method of the promise associated with this deferred object.
  64787. */
  64788. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  64789. /**
  64790. * The reject method of the promise associated with this deferred object.
  64791. */
  64792. readonly reject: (reason?: any) => void;
  64793. /**
  64794. * Constructor for this deferred object.
  64795. */
  64796. constructor();
  64797. }
  64798. }
  64799. declare module BABYLON {
  64800. /**
  64801. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  64802. */
  64803. export class MeshExploder {
  64804. private _centerMesh;
  64805. private _meshes;
  64806. private _meshesOrigins;
  64807. private _toCenterVectors;
  64808. private _scaledDirection;
  64809. private _newPosition;
  64810. private _centerPosition;
  64811. /**
  64812. * Explodes meshes from a center mesh.
  64813. * @param meshes The meshes to explode.
  64814. * @param centerMesh The mesh to be center of explosion.
  64815. */
  64816. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  64817. private _setCenterMesh;
  64818. /**
  64819. * Get class name
  64820. * @returns "MeshExploder"
  64821. */
  64822. getClassName(): string;
  64823. /**
  64824. * "Exploded meshes"
  64825. * @returns Array of meshes with the centerMesh at index 0.
  64826. */
  64827. getMeshes(): Array<Mesh>;
  64828. /**
  64829. * Explodes meshes giving a specific direction
  64830. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  64831. */
  64832. explode(direction?: number): void;
  64833. }
  64834. }
  64835. declare module BABYLON {
  64836. /**
  64837. * Class used to help managing file picking and drag'n'drop
  64838. */
  64839. export class FilesInput {
  64840. /**
  64841. * List of files ready to be loaded
  64842. */
  64843. static readonly FilesToLoad: {
  64844. [key: string]: File;
  64845. };
  64846. /**
  64847. * Callback called when a file is processed
  64848. */
  64849. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  64850. private _engine;
  64851. private _currentScene;
  64852. private _sceneLoadedCallback;
  64853. private _progressCallback;
  64854. private _additionalRenderLoopLogicCallback;
  64855. private _textureLoadingCallback;
  64856. private _startingProcessingFilesCallback;
  64857. private _onReloadCallback;
  64858. private _errorCallback;
  64859. private _elementToMonitor;
  64860. private _sceneFileToLoad;
  64861. private _filesToLoad;
  64862. /**
  64863. * Creates a new FilesInput
  64864. * @param engine defines the rendering engine
  64865. * @param scene defines the hosting scene
  64866. * @param sceneLoadedCallback callback called when scene is loaded
  64867. * @param progressCallback callback called to track progress
  64868. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  64869. * @param textureLoadingCallback callback called when a texture is loading
  64870. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  64871. * @param onReloadCallback callback called when a reload is requested
  64872. * @param errorCallback callback call if an error occurs
  64873. */
  64874. 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);
  64875. private _dragEnterHandler;
  64876. private _dragOverHandler;
  64877. private _dropHandler;
  64878. /**
  64879. * Calls this function to listen to drag'n'drop events on a specific DOM element
  64880. * @param elementToMonitor defines the DOM element to track
  64881. */
  64882. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  64883. /**
  64884. * Release all associated resources
  64885. */
  64886. dispose(): void;
  64887. private renderFunction;
  64888. private drag;
  64889. private drop;
  64890. private _traverseFolder;
  64891. private _processFiles;
  64892. /**
  64893. * Load files from a drop event
  64894. * @param event defines the drop event to use as source
  64895. */
  64896. loadFiles(event: any): void;
  64897. private _processReload;
  64898. /**
  64899. * Reload the current scene from the loaded files
  64900. */
  64901. reload(): void;
  64902. }
  64903. }
  64904. declare module BABYLON {
  64905. /**
  64906. * Defines the root class used to create scene optimization to use with SceneOptimizer
  64907. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64908. */
  64909. export class SceneOptimization {
  64910. /**
  64911. * Defines the priority of this optimization (0 by default which means first in the list)
  64912. */
  64913. priority: number;
  64914. /**
  64915. * Gets a string describing the action executed by the current optimization
  64916. * @returns description string
  64917. */
  64918. getDescription(): string;
  64919. /**
  64920. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64921. * @param scene defines the current scene where to apply this optimization
  64922. * @param optimizer defines the current optimizer
  64923. * @returns true if everything that can be done was applied
  64924. */
  64925. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64926. /**
  64927. * Creates the SceneOptimization object
  64928. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64929. * @param desc defines the description associated with the optimization
  64930. */
  64931. constructor(
  64932. /**
  64933. * Defines the priority of this optimization (0 by default which means first in the list)
  64934. */
  64935. priority?: number);
  64936. }
  64937. /**
  64938. * Defines an optimization used to reduce the size of render target textures
  64939. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64940. */
  64941. export class TextureOptimization extends SceneOptimization {
  64942. /**
  64943. * Defines the priority of this optimization (0 by default which means first in the list)
  64944. */
  64945. priority: number;
  64946. /**
  64947. * 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
  64948. */
  64949. maximumSize: number;
  64950. /**
  64951. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64952. */
  64953. step: number;
  64954. /**
  64955. * Gets a string describing the action executed by the current optimization
  64956. * @returns description string
  64957. */
  64958. getDescription(): string;
  64959. /**
  64960. * Creates the TextureOptimization object
  64961. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64962. * @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
  64963. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64964. */
  64965. constructor(
  64966. /**
  64967. * Defines the priority of this optimization (0 by default which means first in the list)
  64968. */
  64969. priority?: number,
  64970. /**
  64971. * 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
  64972. */
  64973. maximumSize?: number,
  64974. /**
  64975. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64976. */
  64977. step?: number);
  64978. /**
  64979. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64980. * @param scene defines the current scene where to apply this optimization
  64981. * @param optimizer defines the current optimizer
  64982. * @returns true if everything that can be done was applied
  64983. */
  64984. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64985. }
  64986. /**
  64987. * Defines an optimization used to increase or decrease the rendering resolution
  64988. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64989. */
  64990. export class HardwareScalingOptimization extends SceneOptimization {
  64991. /**
  64992. * Defines the priority of this optimization (0 by default which means first in the list)
  64993. */
  64994. priority: number;
  64995. /**
  64996. * Defines the maximum scale to use (2 by default)
  64997. */
  64998. maximumScale: number;
  64999. /**
  65000. * Defines the step to use between two passes (0.5 by default)
  65001. */
  65002. step: number;
  65003. private _currentScale;
  65004. private _directionOffset;
  65005. /**
  65006. * Gets a string describing the action executed by the current optimization
  65007. * @return description string
  65008. */
  65009. getDescription(): string;
  65010. /**
  65011. * Creates the HardwareScalingOptimization object
  65012. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65013. * @param maximumScale defines the maximum scale to use (2 by default)
  65014. * @param step defines the step to use between two passes (0.5 by default)
  65015. */
  65016. constructor(
  65017. /**
  65018. * Defines the priority of this optimization (0 by default which means first in the list)
  65019. */
  65020. priority?: number,
  65021. /**
  65022. * Defines the maximum scale to use (2 by default)
  65023. */
  65024. maximumScale?: number,
  65025. /**
  65026. * Defines the step to use between two passes (0.5 by default)
  65027. */
  65028. step?: number);
  65029. /**
  65030. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65031. * @param scene defines the current scene where to apply this optimization
  65032. * @param optimizer defines the current optimizer
  65033. * @returns true if everything that can be done was applied
  65034. */
  65035. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65036. }
  65037. /**
  65038. * Defines an optimization used to remove shadows
  65039. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65040. */
  65041. export class ShadowsOptimization extends SceneOptimization {
  65042. /**
  65043. * Gets a string describing the action executed by the current optimization
  65044. * @return description string
  65045. */
  65046. getDescription(): string;
  65047. /**
  65048. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65049. * @param scene defines the current scene where to apply this optimization
  65050. * @param optimizer defines the current optimizer
  65051. * @returns true if everything that can be done was applied
  65052. */
  65053. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65054. }
  65055. /**
  65056. * Defines an optimization used to turn post-processes off
  65057. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65058. */
  65059. export class PostProcessesOptimization extends SceneOptimization {
  65060. /**
  65061. * Gets a string describing the action executed by the current optimization
  65062. * @return description string
  65063. */
  65064. getDescription(): string;
  65065. /**
  65066. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65067. * @param scene defines the current scene where to apply this optimization
  65068. * @param optimizer defines the current optimizer
  65069. * @returns true if everything that can be done was applied
  65070. */
  65071. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65072. }
  65073. /**
  65074. * Defines an optimization used to turn lens flares off
  65075. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65076. */
  65077. export class LensFlaresOptimization extends SceneOptimization {
  65078. /**
  65079. * Gets a string describing the action executed by the current optimization
  65080. * @return description string
  65081. */
  65082. getDescription(): string;
  65083. /**
  65084. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65085. * @param scene defines the current scene where to apply this optimization
  65086. * @param optimizer defines the current optimizer
  65087. * @returns true if everything that can be done was applied
  65088. */
  65089. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65090. }
  65091. /**
  65092. * Defines an optimization based on user defined callback.
  65093. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65094. */
  65095. export class CustomOptimization extends SceneOptimization {
  65096. /**
  65097. * Callback called to apply the custom optimization.
  65098. */
  65099. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  65100. /**
  65101. * Callback called to get custom description
  65102. */
  65103. onGetDescription: () => string;
  65104. /**
  65105. * Gets a string describing the action executed by the current optimization
  65106. * @returns description string
  65107. */
  65108. getDescription(): string;
  65109. /**
  65110. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65111. * @param scene defines the current scene where to apply this optimization
  65112. * @param optimizer defines the current optimizer
  65113. * @returns true if everything that can be done was applied
  65114. */
  65115. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65116. }
  65117. /**
  65118. * Defines an optimization used to turn particles off
  65119. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65120. */
  65121. export class ParticlesOptimization extends SceneOptimization {
  65122. /**
  65123. * Gets a string describing the action executed by the current optimization
  65124. * @return description string
  65125. */
  65126. getDescription(): string;
  65127. /**
  65128. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65129. * @param scene defines the current scene where to apply this optimization
  65130. * @param optimizer defines the current optimizer
  65131. * @returns true if everything that can be done was applied
  65132. */
  65133. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65134. }
  65135. /**
  65136. * Defines an optimization used to turn render targets off
  65137. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65138. */
  65139. export class RenderTargetsOptimization extends SceneOptimization {
  65140. /**
  65141. * Gets a string describing the action executed by the current optimization
  65142. * @return description string
  65143. */
  65144. getDescription(): string;
  65145. /**
  65146. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65147. * @param scene defines the current scene where to apply this optimization
  65148. * @param optimizer defines the current optimizer
  65149. * @returns true if everything that can be done was applied
  65150. */
  65151. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65152. }
  65153. /**
  65154. * Defines an optimization used to merge meshes with compatible materials
  65155. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65156. */
  65157. export class MergeMeshesOptimization extends SceneOptimization {
  65158. private static _UpdateSelectionTree;
  65159. /**
  65160. * Gets or sets a boolean which defines if optimization octree has to be updated
  65161. */
  65162. /**
  65163. * Gets or sets a boolean which defines if optimization octree has to be updated
  65164. */
  65165. static UpdateSelectionTree: boolean;
  65166. /**
  65167. * Gets a string describing the action executed by the current optimization
  65168. * @return description string
  65169. */
  65170. getDescription(): string;
  65171. private _canBeMerged;
  65172. /**
  65173. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65174. * @param scene defines the current scene where to apply this optimization
  65175. * @param optimizer defines the current optimizer
  65176. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  65177. * @returns true if everything that can be done was applied
  65178. */
  65179. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  65180. }
  65181. /**
  65182. * Defines a list of options used by SceneOptimizer
  65183. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65184. */
  65185. export class SceneOptimizerOptions {
  65186. /**
  65187. * Defines the target frame rate to reach (60 by default)
  65188. */
  65189. targetFrameRate: number;
  65190. /**
  65191. * Defines the interval between two checkes (2000ms by default)
  65192. */
  65193. trackerDuration: number;
  65194. /**
  65195. * Gets the list of optimizations to apply
  65196. */
  65197. optimizations: SceneOptimization[];
  65198. /**
  65199. * Creates a new list of options used by SceneOptimizer
  65200. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  65201. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  65202. */
  65203. constructor(
  65204. /**
  65205. * Defines the target frame rate to reach (60 by default)
  65206. */
  65207. targetFrameRate?: number,
  65208. /**
  65209. * Defines the interval between two checkes (2000ms by default)
  65210. */
  65211. trackerDuration?: number);
  65212. /**
  65213. * Add a new optimization
  65214. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  65215. * @returns the current SceneOptimizerOptions
  65216. */
  65217. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  65218. /**
  65219. * Add a new custom optimization
  65220. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  65221. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  65222. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65223. * @returns the current SceneOptimizerOptions
  65224. */
  65225. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  65226. /**
  65227. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  65228. * @param targetFrameRate defines the target frame rate (60 by default)
  65229. * @returns a SceneOptimizerOptions object
  65230. */
  65231. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65232. /**
  65233. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  65234. * @param targetFrameRate defines the target frame rate (60 by default)
  65235. * @returns a SceneOptimizerOptions object
  65236. */
  65237. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65238. /**
  65239. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  65240. * @param targetFrameRate defines the target frame rate (60 by default)
  65241. * @returns a SceneOptimizerOptions object
  65242. */
  65243. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65244. }
  65245. /**
  65246. * Class used to run optimizations in order to reach a target frame rate
  65247. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65248. */
  65249. export class SceneOptimizer implements IDisposable {
  65250. private _isRunning;
  65251. private _options;
  65252. private _scene;
  65253. private _currentPriorityLevel;
  65254. private _targetFrameRate;
  65255. private _trackerDuration;
  65256. private _currentFrameRate;
  65257. private _sceneDisposeObserver;
  65258. private _improvementMode;
  65259. /**
  65260. * Defines an observable called when the optimizer reaches the target frame rate
  65261. */
  65262. onSuccessObservable: Observable<SceneOptimizer>;
  65263. /**
  65264. * Defines an observable called when the optimizer enables an optimization
  65265. */
  65266. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  65267. /**
  65268. * Defines an observable called when the optimizer is not able to reach the target frame rate
  65269. */
  65270. onFailureObservable: Observable<SceneOptimizer>;
  65271. /**
  65272. * Gets a boolean indicating if the optimizer is in improvement mode
  65273. */
  65274. readonly isInImprovementMode: boolean;
  65275. /**
  65276. * Gets the current priority level (0 at start)
  65277. */
  65278. readonly currentPriorityLevel: number;
  65279. /**
  65280. * Gets the current frame rate checked by the SceneOptimizer
  65281. */
  65282. readonly currentFrameRate: number;
  65283. /**
  65284. * Gets or sets the current target frame rate (60 by default)
  65285. */
  65286. /**
  65287. * Gets or sets the current target frame rate (60 by default)
  65288. */
  65289. targetFrameRate: number;
  65290. /**
  65291. * Gets or sets the current interval between two checks (every 2000ms by default)
  65292. */
  65293. /**
  65294. * Gets or sets the current interval between two checks (every 2000ms by default)
  65295. */
  65296. trackerDuration: number;
  65297. /**
  65298. * Gets the list of active optimizations
  65299. */
  65300. readonly optimizations: SceneOptimization[];
  65301. /**
  65302. * Creates a new SceneOptimizer
  65303. * @param scene defines the scene to work on
  65304. * @param options defines the options to use with the SceneOptimizer
  65305. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  65306. * @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)
  65307. */
  65308. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  65309. /**
  65310. * Stops the current optimizer
  65311. */
  65312. stop(): void;
  65313. /**
  65314. * Reset the optimizer to initial step (current priority level = 0)
  65315. */
  65316. reset(): void;
  65317. /**
  65318. * Start the optimizer. By default it will try to reach a specific framerate
  65319. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  65320. */
  65321. start(): void;
  65322. private _checkCurrentState;
  65323. /**
  65324. * Release all resources
  65325. */
  65326. dispose(): void;
  65327. /**
  65328. * Helper function to create a SceneOptimizer with one single line of code
  65329. * @param scene defines the scene to work on
  65330. * @param options defines the options to use with the SceneOptimizer
  65331. * @param onSuccess defines a callback to call on success
  65332. * @param onFailure defines a callback to call on failure
  65333. * @returns the new SceneOptimizer object
  65334. */
  65335. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  65336. }
  65337. }
  65338. declare module BABYLON {
  65339. /**
  65340. * Class used to serialize a scene into a string
  65341. */
  65342. export class SceneSerializer {
  65343. /**
  65344. * Clear cache used by a previous serialization
  65345. */
  65346. static ClearCache(): void;
  65347. /**
  65348. * Serialize a scene into a JSON compatible object
  65349. * @param scene defines the scene to serialize
  65350. * @returns a JSON compatible object
  65351. */
  65352. static Serialize(scene: Scene): any;
  65353. /**
  65354. * Serialize a mesh into a JSON compatible object
  65355. * @param toSerialize defines the mesh to serialize
  65356. * @param withParents defines if parents must be serialized as well
  65357. * @param withChildren defines if children must be serialized as well
  65358. * @returns a JSON compatible object
  65359. */
  65360. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  65361. }
  65362. }
  65363. declare module BABYLON {
  65364. /**
  65365. * Class used to host texture specific utilities
  65366. */
  65367. export class TextureTools {
  65368. /**
  65369. * Uses the GPU to create a copy texture rescaled at a given size
  65370. * @param texture Texture to copy from
  65371. * @param width defines the desired width
  65372. * @param height defines the desired height
  65373. * @param useBilinearMode defines if bilinear mode has to be used
  65374. * @return the generated texture
  65375. */
  65376. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  65377. }
  65378. }
  65379. declare module BABYLON {
  65380. /**
  65381. * This represents the different options available for the video capture.
  65382. */
  65383. export interface VideoRecorderOptions {
  65384. /** Defines the mime type of the video. */
  65385. mimeType: string;
  65386. /** Defines the FPS the video should be recorded at. */
  65387. fps: number;
  65388. /** Defines the chunk size for the recording data. */
  65389. recordChunckSize: number;
  65390. /** The audio tracks to attach to the recording. */
  65391. audioTracks?: MediaStreamTrack[];
  65392. }
  65393. /**
  65394. * This can help with recording videos from BabylonJS.
  65395. * This is based on the available WebRTC functionalities of the browser.
  65396. *
  65397. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  65398. */
  65399. export class VideoRecorder {
  65400. private static readonly _defaultOptions;
  65401. /**
  65402. * Returns whether or not the VideoRecorder is available in your browser.
  65403. * @param engine Defines the Babylon Engine.
  65404. * @returns true if supported otherwise false.
  65405. */
  65406. static IsSupported(engine: Engine): boolean;
  65407. private readonly _options;
  65408. private _canvas;
  65409. private _mediaRecorder;
  65410. private _recordedChunks;
  65411. private _fileName;
  65412. private _resolve;
  65413. private _reject;
  65414. /**
  65415. * True when a recording is already in progress.
  65416. */
  65417. readonly isRecording: boolean;
  65418. /**
  65419. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  65420. * @param engine Defines the BabylonJS Engine you wish to record.
  65421. * @param options Defines options that can be used to customize the capture.
  65422. */
  65423. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  65424. /**
  65425. * Stops the current recording before the default capture timeout passed in the startRecording function.
  65426. */
  65427. stopRecording(): void;
  65428. /**
  65429. * Starts recording the canvas for a max duration specified in parameters.
  65430. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  65431. * If null no automatic download will start and you can rely on the promise to get the data back.
  65432. * @param maxDuration Defines the maximum recording time in seconds.
  65433. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  65434. * @return A promise callback at the end of the recording with the video data in Blob.
  65435. */
  65436. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  65437. /**
  65438. * Releases internal resources used during the recording.
  65439. */
  65440. dispose(): void;
  65441. private _handleDataAvailable;
  65442. private _handleError;
  65443. private _handleStop;
  65444. }
  65445. }
  65446. declare module BABYLON {
  65447. /**
  65448. * Class containing a set of static utilities functions for screenshots
  65449. */
  65450. export class ScreenshotTools {
  65451. /**
  65452. * Captures a screenshot of the current rendering
  65453. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65454. * @param engine defines the rendering engine
  65455. * @param camera defines the source camera
  65456. * @param size This parameter can be set to a single number or to an object with the
  65457. * following (optional) properties: precision, width, height. If a single number is passed,
  65458. * it will be used for both width and height. If an object is passed, the screenshot size
  65459. * will be derived from the parameters. The precision property is a multiplier allowing
  65460. * rendering at a higher or lower resolution
  65461. * @param successCallback defines the callback receives a single parameter which contains the
  65462. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65463. * src parameter of an <img> to display it
  65464. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65465. * Check your browser for supported MIME types
  65466. */
  65467. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  65468. /**
  65469. * Captures a screenshot of the current rendering
  65470. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65471. * @param engine defines the rendering engine
  65472. * @param camera defines the source camera
  65473. * @param size This parameter can be set to a single number or to an object with the
  65474. * following (optional) properties: precision, width, height. If a single number is passed,
  65475. * it will be used for both width and height. If an object is passed, the screenshot size
  65476. * will be derived from the parameters. The precision property is a multiplier allowing
  65477. * rendering at a higher or lower resolution
  65478. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65479. * Check your browser for supported MIME types
  65480. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65481. * to the src parameter of an <img> to display it
  65482. */
  65483. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  65484. /**
  65485. * Generates an image screenshot from the specified camera.
  65486. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65487. * @param engine The engine to use for rendering
  65488. * @param camera The camera to use for rendering
  65489. * @param size This parameter can be set to a single number or to an object with the
  65490. * following (optional) properties: precision, width, height. If a single number is passed,
  65491. * it will be used for both width and height. If an object is passed, the screenshot size
  65492. * will be derived from the parameters. The precision property is a multiplier allowing
  65493. * rendering at a higher or lower resolution
  65494. * @param successCallback The callback receives a single parameter which contains the
  65495. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65496. * src parameter of an <img> to display it
  65497. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65498. * Check your browser for supported MIME types
  65499. * @param samples Texture samples (default: 1)
  65500. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65501. * @param fileName A name for for the downloaded file.
  65502. */
  65503. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  65504. /**
  65505. * Generates an image screenshot from the specified camera.
  65506. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65507. * @param engine The engine to use for rendering
  65508. * @param camera The camera to use for rendering
  65509. * @param size This parameter can be set to a single number or to an object with the
  65510. * following (optional) properties: precision, width, height. If a single number is passed,
  65511. * it will be used for both width and height. If an object is passed, the screenshot size
  65512. * will be derived from the parameters. The precision property is a multiplier allowing
  65513. * rendering at a higher or lower resolution
  65514. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65515. * Check your browser for supported MIME types
  65516. * @param samples Texture samples (default: 1)
  65517. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65518. * @param fileName A name for for the downloaded file.
  65519. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65520. * to the src parameter of an <img> to display it
  65521. */
  65522. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  65523. /**
  65524. * Gets height and width for screenshot size
  65525. * @private
  65526. */
  65527. private static _getScreenshotSize;
  65528. }
  65529. }
  65530. declare module BABYLON {
  65531. /**
  65532. * Interface for a data buffer
  65533. */
  65534. export interface IDataBuffer {
  65535. /**
  65536. * Reads bytes from the data buffer.
  65537. * @param byteOffset The byte offset to read
  65538. * @param byteLength The byte length to read
  65539. * @returns A promise that resolves when the bytes are read
  65540. */
  65541. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  65542. /**
  65543. * The byte length of the buffer.
  65544. */
  65545. readonly byteLength: number;
  65546. }
  65547. /**
  65548. * Utility class for reading from a data buffer
  65549. */
  65550. export class DataReader {
  65551. /**
  65552. * The data buffer associated with this data reader.
  65553. */
  65554. readonly buffer: IDataBuffer;
  65555. /**
  65556. * The current byte offset from the beginning of the data buffer.
  65557. */
  65558. byteOffset: number;
  65559. private _dataView;
  65560. private _dataByteOffset;
  65561. /**
  65562. * Constructor
  65563. * @param buffer The buffer to read
  65564. */
  65565. constructor(buffer: IDataBuffer);
  65566. /**
  65567. * Loads the given byte length.
  65568. * @param byteLength The byte length to load
  65569. * @returns A promise that resolves when the load is complete
  65570. */
  65571. loadAsync(byteLength: number): Promise<void>;
  65572. /**
  65573. * Read a unsigned 32-bit integer from the currently loaded data range.
  65574. * @returns The 32-bit integer read
  65575. */
  65576. readUint32(): number;
  65577. /**
  65578. * Read a byte array from the currently loaded data range.
  65579. * @param byteLength The byte length to read
  65580. * @returns The byte array read
  65581. */
  65582. readUint8Array(byteLength: number): Uint8Array;
  65583. /**
  65584. * Read a string from the currently loaded data range.
  65585. * @param byteLength The byte length to read
  65586. * @returns The string read
  65587. */
  65588. readString(byteLength: number): string;
  65589. /**
  65590. * Skips the given byte length the currently loaded data range.
  65591. * @param byteLength The byte length to skip
  65592. */
  65593. skipBytes(byteLength: number): void;
  65594. }
  65595. }
  65596. declare module BABYLON {
  65597. /**
  65598. * A cursor which tracks a point on a path
  65599. */
  65600. export class PathCursor {
  65601. private path;
  65602. /**
  65603. * Stores path cursor callbacks for when an onchange event is triggered
  65604. */
  65605. private _onchange;
  65606. /**
  65607. * The value of the path cursor
  65608. */
  65609. value: number;
  65610. /**
  65611. * The animation array of the path cursor
  65612. */
  65613. animations: Animation[];
  65614. /**
  65615. * Initializes the path cursor
  65616. * @param path The path to track
  65617. */
  65618. constructor(path: Path2);
  65619. /**
  65620. * Gets the cursor point on the path
  65621. * @returns A point on the path cursor at the cursor location
  65622. */
  65623. getPoint(): Vector3;
  65624. /**
  65625. * Moves the cursor ahead by the step amount
  65626. * @param step The amount to move the cursor forward
  65627. * @returns This path cursor
  65628. */
  65629. moveAhead(step?: number): PathCursor;
  65630. /**
  65631. * Moves the cursor behind by the step amount
  65632. * @param step The amount to move the cursor back
  65633. * @returns This path cursor
  65634. */
  65635. moveBack(step?: number): PathCursor;
  65636. /**
  65637. * Moves the cursor by the step amount
  65638. * If the step amount is greater than one, an exception is thrown
  65639. * @param step The amount to move the cursor
  65640. * @returns This path cursor
  65641. */
  65642. move(step: number): PathCursor;
  65643. /**
  65644. * Ensures that the value is limited between zero and one
  65645. * @returns This path cursor
  65646. */
  65647. private ensureLimits;
  65648. /**
  65649. * Runs onchange callbacks on change (used by the animation engine)
  65650. * @returns This path cursor
  65651. */
  65652. private raiseOnChange;
  65653. /**
  65654. * Executes a function on change
  65655. * @param f A path cursor onchange callback
  65656. * @returns This path cursor
  65657. */
  65658. onchange(f: (cursor: PathCursor) => void): PathCursor;
  65659. }
  65660. }
  65661. declare module BABYLON {
  65662. /** @hidden */
  65663. export var blurPixelShader: {
  65664. name: string;
  65665. shader: string;
  65666. };
  65667. }
  65668. declare module BABYLON {
  65669. /** @hidden */
  65670. export var pointCloudVertexDeclaration: {
  65671. name: string;
  65672. shader: string;
  65673. };
  65674. }
  65675. // Mixins
  65676. interface Window {
  65677. mozIndexedDB: IDBFactory;
  65678. webkitIndexedDB: IDBFactory;
  65679. msIndexedDB: IDBFactory;
  65680. webkitURL: typeof URL;
  65681. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  65682. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  65683. WebGLRenderingContext: WebGLRenderingContext;
  65684. MSGesture: MSGesture;
  65685. CANNON: any;
  65686. AudioContext: AudioContext;
  65687. webkitAudioContext: AudioContext;
  65688. PointerEvent: any;
  65689. Math: Math;
  65690. Uint8Array: Uint8ArrayConstructor;
  65691. Float32Array: Float32ArrayConstructor;
  65692. mozURL: typeof URL;
  65693. msURL: typeof URL;
  65694. VRFrameData: any; // WebVR, from specs 1.1
  65695. DracoDecoderModule: any;
  65696. setImmediate(handler: (...args: any[]) => void): number;
  65697. }
  65698. interface HTMLCanvasElement {
  65699. requestPointerLock(): void;
  65700. msRequestPointerLock?(): void;
  65701. mozRequestPointerLock?(): void;
  65702. webkitRequestPointerLock?(): void;
  65703. /** Track wether a record is in progress */
  65704. isRecording: boolean;
  65705. /** Capture Stream method defined by some browsers */
  65706. captureStream(fps?: number): MediaStream;
  65707. }
  65708. interface CanvasRenderingContext2D {
  65709. msImageSmoothingEnabled: boolean;
  65710. }
  65711. interface MouseEvent {
  65712. mozMovementX: number;
  65713. mozMovementY: number;
  65714. webkitMovementX: number;
  65715. webkitMovementY: number;
  65716. msMovementX: number;
  65717. msMovementY: number;
  65718. }
  65719. interface Navigator {
  65720. mozGetVRDevices: (any: any) => any;
  65721. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  65722. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  65723. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  65724. webkitGetGamepads(): Gamepad[];
  65725. msGetGamepads(): Gamepad[];
  65726. webkitGamepads(): Gamepad[];
  65727. }
  65728. interface HTMLVideoElement {
  65729. mozSrcObject: any;
  65730. }
  65731. interface Math {
  65732. fround(x: number): number;
  65733. imul(a: number, b: number): number;
  65734. }
  65735. interface WebGLRenderingContext {
  65736. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  65737. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  65738. vertexAttribDivisor(index: number, divisor: number): void;
  65739. createVertexArray(): any;
  65740. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  65741. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  65742. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  65743. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  65744. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  65745. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  65746. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  65747. // Queries
  65748. createQuery(): WebGLQuery;
  65749. deleteQuery(query: WebGLQuery): void;
  65750. beginQuery(target: number, query: WebGLQuery): void;
  65751. endQuery(target: number): void;
  65752. getQueryParameter(query: WebGLQuery, pname: number): any;
  65753. getQuery(target: number, pname: number): any;
  65754. MAX_SAMPLES: number;
  65755. RGBA8: number;
  65756. READ_FRAMEBUFFER: number;
  65757. DRAW_FRAMEBUFFER: number;
  65758. UNIFORM_BUFFER: number;
  65759. HALF_FLOAT_OES: number;
  65760. RGBA16F: number;
  65761. RGBA32F: number;
  65762. R32F: number;
  65763. RG32F: number;
  65764. RGB32F: number;
  65765. R16F: number;
  65766. RG16F: number;
  65767. RGB16F: number;
  65768. RED: number;
  65769. RG: number;
  65770. R8: number;
  65771. RG8: number;
  65772. UNSIGNED_INT_24_8: number;
  65773. DEPTH24_STENCIL8: number;
  65774. MIN: number;
  65775. MAX: number;
  65776. /* Multiple Render Targets */
  65777. drawBuffers(buffers: number[]): void;
  65778. readBuffer(src: number): void;
  65779. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  65780. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  65781. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  65782. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  65783. // Occlusion Query
  65784. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  65785. ANY_SAMPLES_PASSED: number;
  65786. QUERY_RESULT_AVAILABLE: number;
  65787. QUERY_RESULT: number;
  65788. }
  65789. interface WebGLProgram {
  65790. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  65791. }
  65792. interface EXT_disjoint_timer_query {
  65793. QUERY_COUNTER_BITS_EXT: number;
  65794. TIME_ELAPSED_EXT: number;
  65795. TIMESTAMP_EXT: number;
  65796. GPU_DISJOINT_EXT: number;
  65797. QUERY_RESULT_EXT: number;
  65798. QUERY_RESULT_AVAILABLE_EXT: number;
  65799. queryCounterEXT(query: WebGLQuery, target: number): void;
  65800. createQueryEXT(): WebGLQuery;
  65801. beginQueryEXT(target: number, query: WebGLQuery): void;
  65802. endQueryEXT(target: number): void;
  65803. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  65804. deleteQueryEXT(query: WebGLQuery): void;
  65805. }
  65806. interface WebGLUniformLocation {
  65807. _currentState: any;
  65808. }
  65809. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  65810. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  65811. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  65812. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  65813. interface WebGLRenderingContext {
  65814. readonly RASTERIZER_DISCARD: number;
  65815. readonly DEPTH_COMPONENT24: number;
  65816. readonly TEXTURE_3D: number;
  65817. readonly TEXTURE_2D_ARRAY: number;
  65818. readonly TEXTURE_COMPARE_FUNC: number;
  65819. readonly TEXTURE_COMPARE_MODE: number;
  65820. readonly COMPARE_REF_TO_TEXTURE: number;
  65821. readonly TEXTURE_WRAP_R: number;
  65822. readonly HALF_FLOAT: number;
  65823. readonly RGB8: number;
  65824. readonly RED_INTEGER: number;
  65825. readonly RG_INTEGER: number;
  65826. readonly RGB_INTEGER: number;
  65827. readonly RGBA_INTEGER: number;
  65828. readonly R8_SNORM: number;
  65829. readonly RG8_SNORM: number;
  65830. readonly RGB8_SNORM: number;
  65831. readonly RGBA8_SNORM: number;
  65832. readonly R8I: number;
  65833. readonly RG8I: number;
  65834. readonly RGB8I: number;
  65835. readonly RGBA8I: number;
  65836. readonly R8UI: number;
  65837. readonly RG8UI: number;
  65838. readonly RGB8UI: number;
  65839. readonly RGBA8UI: number;
  65840. readonly R16I: number;
  65841. readonly RG16I: number;
  65842. readonly RGB16I: number;
  65843. readonly RGBA16I: number;
  65844. readonly R16UI: number;
  65845. readonly RG16UI: number;
  65846. readonly RGB16UI: number;
  65847. readonly RGBA16UI: number;
  65848. readonly R32I: number;
  65849. readonly RG32I: number;
  65850. readonly RGB32I: number;
  65851. readonly RGBA32I: number;
  65852. readonly R32UI: number;
  65853. readonly RG32UI: number;
  65854. readonly RGB32UI: number;
  65855. readonly RGBA32UI: number;
  65856. readonly RGB10_A2UI: number;
  65857. readonly R11F_G11F_B10F: number;
  65858. readonly RGB9_E5: number;
  65859. readonly RGB10_A2: number;
  65860. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  65861. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  65862. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  65863. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  65864. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  65865. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  65866. 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;
  65867. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  65868. readonly TRANSFORM_FEEDBACK: number;
  65869. readonly INTERLEAVED_ATTRIBS: number;
  65870. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  65871. createTransformFeedback(): WebGLTransformFeedback;
  65872. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  65873. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  65874. beginTransformFeedback(primitiveMode: number): void;
  65875. endTransformFeedback(): void;
  65876. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  65877. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  65878. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  65879. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  65880. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  65881. }
  65882. interface ImageBitmap {
  65883. readonly width: number;
  65884. readonly height: number;
  65885. close(): void;
  65886. }
  65887. interface WebGLQuery extends WebGLObject {
  65888. }
  65889. declare var WebGLQuery: {
  65890. prototype: WebGLQuery;
  65891. new(): WebGLQuery;
  65892. };
  65893. interface WebGLSampler extends WebGLObject {
  65894. }
  65895. declare var WebGLSampler: {
  65896. prototype: WebGLSampler;
  65897. new(): WebGLSampler;
  65898. };
  65899. interface WebGLSync extends WebGLObject {
  65900. }
  65901. declare var WebGLSync: {
  65902. prototype: WebGLSync;
  65903. new(): WebGLSync;
  65904. };
  65905. interface WebGLTransformFeedback extends WebGLObject {
  65906. }
  65907. declare var WebGLTransformFeedback: {
  65908. prototype: WebGLTransformFeedback;
  65909. new(): WebGLTransformFeedback;
  65910. };
  65911. interface WebGLVertexArrayObject extends WebGLObject {
  65912. }
  65913. declare var WebGLVertexArrayObject: {
  65914. prototype: WebGLVertexArrayObject;
  65915. new(): WebGLVertexArrayObject;
  65916. };
  65917. // Type definitions for WebVR API
  65918. // Project: https://w3c.github.io/webvr/
  65919. // Definitions by: six a <https://github.com/lostfictions>
  65920. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  65921. interface VRDisplay extends EventTarget {
  65922. /**
  65923. * Dictionary of capabilities describing the VRDisplay.
  65924. */
  65925. readonly capabilities: VRDisplayCapabilities;
  65926. /**
  65927. * z-depth defining the far plane of the eye view frustum
  65928. * enables mapping of values in the render target depth
  65929. * attachment to scene coordinates. Initially set to 10000.0.
  65930. */
  65931. depthFar: number;
  65932. /**
  65933. * z-depth defining the near plane of the eye view frustum
  65934. * enables mapping of values in the render target depth
  65935. * attachment to scene coordinates. Initially set to 0.01.
  65936. */
  65937. depthNear: number;
  65938. /**
  65939. * An identifier for this distinct VRDisplay. Used as an
  65940. * association point in the Gamepad API.
  65941. */
  65942. readonly displayId: number;
  65943. /**
  65944. * A display name, a user-readable name identifying it.
  65945. */
  65946. readonly displayName: string;
  65947. readonly isConnected: boolean;
  65948. readonly isPresenting: boolean;
  65949. /**
  65950. * If this VRDisplay supports room-scale experiences, the optional
  65951. * stage attribute contains details on the room-scale parameters.
  65952. */
  65953. readonly stageParameters: VRStageParameters | null;
  65954. /**
  65955. * Passing the value returned by `requestAnimationFrame` to
  65956. * `cancelAnimationFrame` will unregister the callback.
  65957. * @param handle Define the hanle of the request to cancel
  65958. */
  65959. cancelAnimationFrame(handle: number): void;
  65960. /**
  65961. * Stops presenting to the VRDisplay.
  65962. * @returns a promise to know when it stopped
  65963. */
  65964. exitPresent(): Promise<void>;
  65965. /**
  65966. * Return the current VREyeParameters for the given eye.
  65967. * @param whichEye Define the eye we want the parameter for
  65968. * @returns the eye parameters
  65969. */
  65970. getEyeParameters(whichEye: string): VREyeParameters;
  65971. /**
  65972. * Populates the passed VRFrameData with the information required to render
  65973. * the current frame.
  65974. * @param frameData Define the data structure to populate
  65975. * @returns true if ok otherwise false
  65976. */
  65977. getFrameData(frameData: VRFrameData): boolean;
  65978. /**
  65979. * Get the layers currently being presented.
  65980. * @returns the list of VR layers
  65981. */
  65982. getLayers(): VRLayer[];
  65983. /**
  65984. * Return a VRPose containing the future predicted pose of the VRDisplay
  65985. * when the current frame will be presented. The value returned will not
  65986. * change until JavaScript has returned control to the browser.
  65987. *
  65988. * The VRPose will contain the position, orientation, velocity,
  65989. * and acceleration of each of these properties.
  65990. * @returns the pose object
  65991. */
  65992. getPose(): VRPose;
  65993. /**
  65994. * Return the current instantaneous pose of the VRDisplay, with no
  65995. * prediction applied.
  65996. * @returns the current instantaneous pose
  65997. */
  65998. getImmediatePose(): VRPose;
  65999. /**
  66000. * The callback passed to `requestAnimationFrame` will be called
  66001. * any time a new frame should be rendered. When the VRDisplay is
  66002. * presenting the callback will be called at the native refresh
  66003. * rate of the HMD. When not presenting this function acts
  66004. * identically to how window.requestAnimationFrame acts. Content should
  66005. * make no assumptions of frame rate or vsync behavior as the HMD runs
  66006. * asynchronously from other displays and at differing refresh rates.
  66007. * @param callback Define the eaction to run next frame
  66008. * @returns the request handle it
  66009. */
  66010. requestAnimationFrame(callback: FrameRequestCallback): number;
  66011. /**
  66012. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  66013. * Repeat calls while already presenting will update the VRLayers being displayed.
  66014. * @param layers Define the list of layer to present
  66015. * @returns a promise to know when the request has been fulfilled
  66016. */
  66017. requestPresent(layers: VRLayer[]): Promise<void>;
  66018. /**
  66019. * Reset the pose for this display, treating its current position and
  66020. * orientation as the "origin/zero" values. VRPose.position,
  66021. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  66022. * updated when calling resetPose(). This should be called in only
  66023. * sitting-space experiences.
  66024. */
  66025. resetPose(): void;
  66026. /**
  66027. * The VRLayer provided to the VRDisplay will be captured and presented
  66028. * in the HMD. Calling this function has the same effect on the source
  66029. * canvas as any other operation that uses its source image, and canvases
  66030. * created without preserveDrawingBuffer set to true will be cleared.
  66031. * @param pose Define the pose to submit
  66032. */
  66033. submitFrame(pose?: VRPose): void;
  66034. }
  66035. declare var VRDisplay: {
  66036. prototype: VRDisplay;
  66037. new(): VRDisplay;
  66038. };
  66039. interface VRLayer {
  66040. leftBounds?: number[] | Float32Array | null;
  66041. rightBounds?: number[] | Float32Array | null;
  66042. source?: HTMLCanvasElement | null;
  66043. }
  66044. interface VRDisplayCapabilities {
  66045. readonly canPresent: boolean;
  66046. readonly hasExternalDisplay: boolean;
  66047. readonly hasOrientation: boolean;
  66048. readonly hasPosition: boolean;
  66049. readonly maxLayers: number;
  66050. }
  66051. interface VREyeParameters {
  66052. /** @deprecated */
  66053. readonly fieldOfView: VRFieldOfView;
  66054. readonly offset: Float32Array;
  66055. readonly renderHeight: number;
  66056. readonly renderWidth: number;
  66057. }
  66058. interface VRFieldOfView {
  66059. readonly downDegrees: number;
  66060. readonly leftDegrees: number;
  66061. readonly rightDegrees: number;
  66062. readonly upDegrees: number;
  66063. }
  66064. interface VRFrameData {
  66065. readonly leftProjectionMatrix: Float32Array;
  66066. readonly leftViewMatrix: Float32Array;
  66067. readonly pose: VRPose;
  66068. readonly rightProjectionMatrix: Float32Array;
  66069. readonly rightViewMatrix: Float32Array;
  66070. readonly timestamp: number;
  66071. }
  66072. interface VRPose {
  66073. readonly angularAcceleration: Float32Array | null;
  66074. readonly angularVelocity: Float32Array | null;
  66075. readonly linearAcceleration: Float32Array | null;
  66076. readonly linearVelocity: Float32Array | null;
  66077. readonly orientation: Float32Array | null;
  66078. readonly position: Float32Array | null;
  66079. readonly timestamp: number;
  66080. }
  66081. interface VRStageParameters {
  66082. sittingToStandingTransform?: Float32Array;
  66083. sizeX?: number;
  66084. sizeY?: number;
  66085. }
  66086. interface Navigator {
  66087. getVRDisplays(): Promise<VRDisplay[]>;
  66088. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  66089. }
  66090. interface Window {
  66091. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  66092. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  66093. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  66094. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  66095. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  66096. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  66097. }
  66098. interface Gamepad {
  66099. readonly displayId: number;
  66100. }
  66101. type XRSessionMode =
  66102. | "inline"
  66103. | "immersive-vr"
  66104. | "immersive-ar";
  66105. type XRReferenceSpaceType =
  66106. | "viewer"
  66107. | "local"
  66108. | "local-floor"
  66109. | "bounded-floor"
  66110. | "unbounded";
  66111. type XREnvironmentBlendMode =
  66112. | "opaque"
  66113. | "additive"
  66114. | "alpha-blend";
  66115. type XRVisibilityState =
  66116. | "visible"
  66117. | "visible-blurred"
  66118. | "hidden";
  66119. type XRHandedness =
  66120. | "none"
  66121. | "left"
  66122. | "right";
  66123. type XRTargetRayMode =
  66124. | "gaze"
  66125. | "tracked-pointer"
  66126. | "screen";
  66127. type XREye =
  66128. | "none"
  66129. | "left"
  66130. | "right";
  66131. interface XRSpace extends EventTarget {
  66132. }
  66133. interface XRRenderState {
  66134. depthNear?: number;
  66135. depthFar?: number;
  66136. inlineVerticalFieldOfView?: number;
  66137. baseLayer?: XRWebGLLayer;
  66138. }
  66139. interface XRInputSource {
  66140. handedness: XRHandedness;
  66141. targetRayMode: XRTargetRayMode;
  66142. targetRaySpace: XRSpace;
  66143. gripSpace: XRSpace | undefined;
  66144. gamepad: Gamepad | undefined;
  66145. profiles: Array<string>;
  66146. }
  66147. interface XRSession {
  66148. addEventListener: Function;
  66149. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  66150. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  66151. requestAnimationFrame: Function;
  66152. end(): Promise<void>;
  66153. renderState: XRRenderState;
  66154. inputSources: Array<XRInputSource>;
  66155. }
  66156. interface XRReferenceSpace extends XRSpace {
  66157. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  66158. onreset: any;
  66159. }
  66160. interface XRFrame {
  66161. session: XRSession;
  66162. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  66163. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  66164. }
  66165. interface XRViewerPose extends XRPose {
  66166. views: Array<XRView>;
  66167. }
  66168. interface XRPose {
  66169. transform: XRRigidTransform;
  66170. emulatedPosition: boolean;
  66171. }
  66172. interface XRWebGLLayerOptions {
  66173. antialias ?: boolean;
  66174. depth ?: boolean;
  66175. stencil ?: boolean;
  66176. alpha ?: boolean;
  66177. multiview ?: boolean;
  66178. framebufferScaleFactor ?: number;
  66179. }
  66180. declare var XRWebGLLayer: {
  66181. prototype: XRWebGLLayer;
  66182. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  66183. };
  66184. interface XRWebGLLayer {
  66185. framebuffer: WebGLFramebuffer;
  66186. framebufferWidth: number;
  66187. framebufferHeight: number;
  66188. getViewport: Function;
  66189. }
  66190. interface XRRigidTransform {
  66191. position: DOMPointReadOnly;
  66192. orientation: DOMPointReadOnly;
  66193. matrix: Float32Array;
  66194. inverse: XRRigidTransform;
  66195. }
  66196. interface XRView {
  66197. eye: XREye;
  66198. projectionMatrix: Float32Array;
  66199. transform: XRRigidTransform;
  66200. }
  66201. interface XRInputSourceChangeEvent {
  66202. session: XRSession;
  66203. removed: Array<XRInputSource>;
  66204. added: Array<XRInputSource>;
  66205. }
  66206. interface XRInputSourceEvent extends Event {
  66207. readonly frame: XRFrame;
  66208. readonly inputSource: XRInputSource;
  66209. }
  66210. /**
  66211. * @ignore
  66212. */
  66213. declare module BABYLON.GLTF2.Exporter {
  66214. }
  66215. /**
  66216. * @ignore
  66217. */
  66218. declare module BABYLON.GLTF1 {
  66219. }
  66220. declare module BABYLON.GUI {
  66221. /**
  66222. * Class used to specific a value and its associated unit
  66223. */
  66224. export class ValueAndUnit {
  66225. /** defines the unit to store */
  66226. unit: number;
  66227. /** defines a boolean indicating if the value can be negative */
  66228. negativeValueAllowed: boolean;
  66229. private _value;
  66230. private _originalUnit;
  66231. /**
  66232. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  66233. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  66234. */
  66235. ignoreAdaptiveScaling: boolean;
  66236. /**
  66237. * Creates a new ValueAndUnit
  66238. * @param value defines the value to store
  66239. * @param unit defines the unit to store
  66240. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  66241. */
  66242. constructor(value: number,
  66243. /** defines the unit to store */
  66244. unit?: number,
  66245. /** defines a boolean indicating if the value can be negative */
  66246. negativeValueAllowed?: boolean);
  66247. /** Gets a boolean indicating if the value is a percentage */
  66248. readonly isPercentage: boolean;
  66249. /** Gets a boolean indicating if the value is store as pixel */
  66250. readonly isPixel: boolean;
  66251. /** Gets direct internal value */
  66252. readonly internalValue: number;
  66253. /**
  66254. * Gets value as pixel
  66255. * @param host defines the root host
  66256. * @param refValue defines the reference value for percentages
  66257. * @returns the value as pixel
  66258. */
  66259. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  66260. /**
  66261. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  66262. * @param value defines the value to store
  66263. * @param unit defines the unit to store
  66264. * @returns the current ValueAndUnit
  66265. */
  66266. updateInPlace(value: number, unit?: number): ValueAndUnit;
  66267. /**
  66268. * Gets the value accordingly to its unit
  66269. * @param host defines the root host
  66270. * @returns the value
  66271. */
  66272. getValue(host: AdvancedDynamicTexture): number;
  66273. /**
  66274. * Gets a string representation of the value
  66275. * @param host defines the root host
  66276. * @param decimals defines an optional number of decimals to display
  66277. * @returns a string
  66278. */
  66279. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  66280. /**
  66281. * Store a value parsed from a string
  66282. * @param source defines the source string
  66283. * @returns true if the value was successfully parsed
  66284. */
  66285. fromString(source: string | number): boolean;
  66286. private static _Regex;
  66287. private static _UNITMODE_PERCENTAGE;
  66288. private static _UNITMODE_PIXEL;
  66289. /** UNITMODE_PERCENTAGE */
  66290. static readonly UNITMODE_PERCENTAGE: number;
  66291. /** UNITMODE_PIXEL */
  66292. static readonly UNITMODE_PIXEL: number;
  66293. }
  66294. }
  66295. declare module BABYLON.GUI {
  66296. /**
  66297. * Define a style used by control to automatically setup properties based on a template.
  66298. * Only support font related properties so far
  66299. */
  66300. export class Style implements BABYLON.IDisposable {
  66301. private _fontFamily;
  66302. private _fontStyle;
  66303. private _fontWeight;
  66304. /** @hidden */
  66305. _host: AdvancedDynamicTexture;
  66306. /** @hidden */
  66307. _fontSize: ValueAndUnit;
  66308. /**
  66309. * BABYLON.Observable raised when the style values are changed
  66310. */
  66311. onChangedObservable: BABYLON.Observable<Style>;
  66312. /**
  66313. * Creates a new style object
  66314. * @param host defines the AdvancedDynamicTexture which hosts this style
  66315. */
  66316. constructor(host: AdvancedDynamicTexture);
  66317. /**
  66318. * Gets or sets the font size
  66319. */
  66320. fontSize: string | number;
  66321. /**
  66322. * Gets or sets the font family
  66323. */
  66324. fontFamily: string;
  66325. /**
  66326. * Gets or sets the font style
  66327. */
  66328. fontStyle: string;
  66329. /** Gets or sets font weight */
  66330. fontWeight: string;
  66331. /** Dispose all associated resources */
  66332. dispose(): void;
  66333. }
  66334. }
  66335. declare module BABYLON.GUI {
  66336. /**
  66337. * Class used to transport BABYLON.Vector2 information for pointer events
  66338. */
  66339. export class Vector2WithInfo extends BABYLON.Vector2 {
  66340. /** defines the current mouse button index */
  66341. buttonIndex: number;
  66342. /**
  66343. * Creates a new Vector2WithInfo
  66344. * @param source defines the vector2 data to transport
  66345. * @param buttonIndex defines the current mouse button index
  66346. */
  66347. constructor(source: BABYLON.Vector2,
  66348. /** defines the current mouse button index */
  66349. buttonIndex?: number);
  66350. }
  66351. /** Class used to provide 2D matrix features */
  66352. export class Matrix2D {
  66353. /** Gets the internal array of 6 floats used to store matrix data */
  66354. m: Float32Array;
  66355. /**
  66356. * Creates a new matrix
  66357. * @param m00 defines value for (0, 0)
  66358. * @param m01 defines value for (0, 1)
  66359. * @param m10 defines value for (1, 0)
  66360. * @param m11 defines value for (1, 1)
  66361. * @param m20 defines value for (2, 0)
  66362. * @param m21 defines value for (2, 1)
  66363. */
  66364. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  66365. /**
  66366. * Fills the matrix from direct values
  66367. * @param m00 defines value for (0, 0)
  66368. * @param m01 defines value for (0, 1)
  66369. * @param m10 defines value for (1, 0)
  66370. * @param m11 defines value for (1, 1)
  66371. * @param m20 defines value for (2, 0)
  66372. * @param m21 defines value for (2, 1)
  66373. * @returns the current modified matrix
  66374. */
  66375. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  66376. /**
  66377. * Gets matrix determinant
  66378. * @returns the determinant
  66379. */
  66380. determinant(): number;
  66381. /**
  66382. * Inverses the matrix and stores it in a target matrix
  66383. * @param result defines the target matrix
  66384. * @returns the current matrix
  66385. */
  66386. invertToRef(result: Matrix2D): Matrix2D;
  66387. /**
  66388. * Multiplies the current matrix with another one
  66389. * @param other defines the second operand
  66390. * @param result defines the target matrix
  66391. * @returns the current matrix
  66392. */
  66393. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  66394. /**
  66395. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  66396. * @param x defines the x coordinate to transform
  66397. * @param y defines the x coordinate to transform
  66398. * @param result defines the target vector2
  66399. * @returns the current matrix
  66400. */
  66401. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  66402. /**
  66403. * Creates an identity matrix
  66404. * @returns a new matrix
  66405. */
  66406. static Identity(): Matrix2D;
  66407. /**
  66408. * Creates a translation matrix and stores it in a target matrix
  66409. * @param x defines the x coordinate of the translation
  66410. * @param y defines the y coordinate of the translation
  66411. * @param result defines the target matrix
  66412. */
  66413. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  66414. /**
  66415. * Creates a scaling matrix and stores it in a target matrix
  66416. * @param x defines the x coordinate of the scaling
  66417. * @param y defines the y coordinate of the scaling
  66418. * @param result defines the target matrix
  66419. */
  66420. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  66421. /**
  66422. * Creates a rotation matrix and stores it in a target matrix
  66423. * @param angle defines the rotation angle
  66424. * @param result defines the target matrix
  66425. */
  66426. static RotationToRef(angle: number, result: Matrix2D): void;
  66427. private static _TempPreTranslationMatrix;
  66428. private static _TempPostTranslationMatrix;
  66429. private static _TempRotationMatrix;
  66430. private static _TempScalingMatrix;
  66431. private static _TempCompose0;
  66432. private static _TempCompose1;
  66433. private static _TempCompose2;
  66434. /**
  66435. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  66436. * @param tx defines the x coordinate of the translation
  66437. * @param ty defines the y coordinate of the translation
  66438. * @param angle defines the rotation angle
  66439. * @param scaleX defines the x coordinate of the scaling
  66440. * @param scaleY defines the y coordinate of the scaling
  66441. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  66442. * @param result defines the target matrix
  66443. */
  66444. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  66445. }
  66446. }
  66447. declare module BABYLON.GUI {
  66448. /**
  66449. * Class used to store 2D control sizes
  66450. */
  66451. export class Measure {
  66452. /** defines left coordinate */
  66453. left: number;
  66454. /** defines top coordinate */
  66455. top: number;
  66456. /** defines width dimension */
  66457. width: number;
  66458. /** defines height dimension */
  66459. height: number;
  66460. /**
  66461. * Creates a new measure
  66462. * @param left defines left coordinate
  66463. * @param top defines top coordinate
  66464. * @param width defines width dimension
  66465. * @param height defines height dimension
  66466. */
  66467. constructor(
  66468. /** defines left coordinate */
  66469. left: number,
  66470. /** defines top coordinate */
  66471. top: number,
  66472. /** defines width dimension */
  66473. width: number,
  66474. /** defines height dimension */
  66475. height: number);
  66476. /**
  66477. * Copy from another measure
  66478. * @param other defines the other measure to copy from
  66479. */
  66480. copyFrom(other: Measure): void;
  66481. /**
  66482. * Copy from a group of 4 floats
  66483. * @param left defines left coordinate
  66484. * @param top defines top coordinate
  66485. * @param width defines width dimension
  66486. * @param height defines height dimension
  66487. */
  66488. copyFromFloats(left: number, top: number, width: number, height: number): void;
  66489. /**
  66490. * Computes the axis aligned bounding box measure for two given measures
  66491. * @param a Input measure
  66492. * @param b Input measure
  66493. * @param result the resulting bounding measure
  66494. */
  66495. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  66496. /**
  66497. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  66498. * @param transform the matrix to transform the measure before computing the AABB
  66499. * @param result the resulting AABB
  66500. */
  66501. transformToRef(transform: Matrix2D, result: Measure): void;
  66502. /**
  66503. * Check equality between this measure and another one
  66504. * @param other defines the other measures
  66505. * @returns true if both measures are equals
  66506. */
  66507. isEqualsTo(other: Measure): boolean;
  66508. /**
  66509. * Creates an empty measure
  66510. * @returns a new measure
  66511. */
  66512. static Empty(): Measure;
  66513. }
  66514. }
  66515. declare module BABYLON.GUI {
  66516. /**
  66517. * Interface used to define a control that can receive focus
  66518. */
  66519. export interface IFocusableControl {
  66520. /**
  66521. * Function called when the control receives the focus
  66522. */
  66523. onFocus(): void;
  66524. /**
  66525. * Function called when the control loses the focus
  66526. */
  66527. onBlur(): void;
  66528. /**
  66529. * Function called to let the control handle keyboard events
  66530. * @param evt defines the current keyboard event
  66531. */
  66532. processKeyboard(evt: KeyboardEvent): void;
  66533. /**
  66534. * Function called to get the list of controls that should not steal the focus from this control
  66535. * @returns an array of controls
  66536. */
  66537. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  66538. }
  66539. /**
  66540. * Class used to create texture to support 2D GUI elements
  66541. * @see http://doc.babylonjs.com/how_to/gui
  66542. */
  66543. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  66544. private _isDirty;
  66545. private _renderObserver;
  66546. private _resizeObserver;
  66547. private _preKeyboardObserver;
  66548. private _pointerMoveObserver;
  66549. private _pointerObserver;
  66550. private _canvasPointerOutObserver;
  66551. private _background;
  66552. /** @hidden */
  66553. _rootContainer: Container;
  66554. /** @hidden */
  66555. _lastPickedControl: Control;
  66556. /** @hidden */
  66557. _lastControlOver: {
  66558. [pointerId: number]: Control;
  66559. };
  66560. /** @hidden */
  66561. _lastControlDown: {
  66562. [pointerId: number]: Control;
  66563. };
  66564. /** @hidden */
  66565. _capturingControl: {
  66566. [pointerId: number]: Control;
  66567. };
  66568. /** @hidden */
  66569. _shouldBlockPointer: boolean;
  66570. /** @hidden */
  66571. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  66572. /** @hidden */
  66573. _linkedControls: Control[];
  66574. private _isFullscreen;
  66575. private _fullscreenViewport;
  66576. private _idealWidth;
  66577. private _idealHeight;
  66578. private _useSmallestIdeal;
  66579. private _renderAtIdealSize;
  66580. private _focusedControl;
  66581. private _blockNextFocusCheck;
  66582. private _renderScale;
  66583. private _rootElement;
  66584. private _cursorChanged;
  66585. /**
  66586. * Define type to string to ensure compatibility across browsers
  66587. * Safari doesn't support DataTransfer constructor
  66588. */
  66589. private _clipboardData;
  66590. /**
  66591. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  66592. */
  66593. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  66594. /**
  66595. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  66596. */
  66597. onControlPickedObservable: BABYLON.Observable<Control>;
  66598. /**
  66599. * BABYLON.Observable event triggered before layout is evaluated
  66600. */
  66601. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  66602. /**
  66603. * BABYLON.Observable event triggered after the layout was evaluated
  66604. */
  66605. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  66606. /**
  66607. * BABYLON.Observable event triggered before the texture is rendered
  66608. */
  66609. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  66610. /**
  66611. * BABYLON.Observable event triggered after the texture was rendered
  66612. */
  66613. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  66614. /**
  66615. * Gets or sets a boolean defining if alpha is stored as premultiplied
  66616. */
  66617. premulAlpha: boolean;
  66618. /**
  66619. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  66620. * Useful when you want more antialiasing
  66621. */
  66622. renderScale: number;
  66623. /** Gets or sets the background color */
  66624. background: string;
  66625. /**
  66626. * Gets or sets the ideal width used to design controls.
  66627. * The GUI will then rescale everything accordingly
  66628. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  66629. */
  66630. idealWidth: number;
  66631. /**
  66632. * Gets or sets the ideal height used to design controls.
  66633. * The GUI will then rescale everything accordingly
  66634. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  66635. */
  66636. idealHeight: number;
  66637. /**
  66638. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  66639. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  66640. */
  66641. useSmallestIdeal: boolean;
  66642. /**
  66643. * Gets or sets a boolean indicating if adaptive scaling must be used
  66644. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  66645. */
  66646. renderAtIdealSize: boolean;
  66647. /**
  66648. * Gets the underlying layer used to render the texture when in fullscreen mode
  66649. */
  66650. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  66651. /**
  66652. * Gets the root container control
  66653. */
  66654. readonly rootContainer: Container;
  66655. /**
  66656. * Returns an array containing the root container.
  66657. * This is mostly used to let the Inspector introspects the ADT
  66658. * @returns an array containing the rootContainer
  66659. */
  66660. getChildren(): Array<Container>;
  66661. /**
  66662. * Will return all controls that are inside this texture
  66663. * @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
  66664. * @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
  66665. * @return all child controls
  66666. */
  66667. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  66668. /**
  66669. * Gets or sets the current focused control
  66670. */
  66671. focusedControl: BABYLON.Nullable<IFocusableControl>;
  66672. /**
  66673. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  66674. */
  66675. isForeground: boolean;
  66676. /**
  66677. * Gets or set information about clipboardData
  66678. */
  66679. clipboardData: string;
  66680. /**
  66681. * Creates a new AdvancedDynamicTexture
  66682. * @param name defines the name of the texture
  66683. * @param width defines the width of the texture
  66684. * @param height defines the height of the texture
  66685. * @param scene defines the hosting scene
  66686. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  66687. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  66688. */
  66689. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  66690. /**
  66691. * Get the current class name of the texture useful for serialization or dynamic coding.
  66692. * @returns "AdvancedDynamicTexture"
  66693. */
  66694. getClassName(): string;
  66695. /**
  66696. * Function used to execute a function on all controls
  66697. * @param func defines the function to execute
  66698. * @param container defines the container where controls belong. If null the root container will be used
  66699. */
  66700. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  66701. private _useInvalidateRectOptimization;
  66702. /**
  66703. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  66704. */
  66705. useInvalidateRectOptimization: boolean;
  66706. private _invalidatedRectangle;
  66707. /**
  66708. * Invalidates a rectangle area on the gui texture
  66709. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  66710. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  66711. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  66712. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  66713. */
  66714. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  66715. /**
  66716. * Marks the texture as dirty forcing a complete update
  66717. */
  66718. markAsDirty(): void;
  66719. /**
  66720. * Helper function used to create a new style
  66721. * @returns a new style
  66722. * @see http://doc.babylonjs.com/how_to/gui#styles
  66723. */
  66724. createStyle(): Style;
  66725. /**
  66726. * Adds a new control to the root container
  66727. * @param control defines the control to add
  66728. * @returns the current texture
  66729. */
  66730. addControl(control: Control): AdvancedDynamicTexture;
  66731. /**
  66732. * Removes a control from the root container
  66733. * @param control defines the control to remove
  66734. * @returns the current texture
  66735. */
  66736. removeControl(control: Control): AdvancedDynamicTexture;
  66737. /**
  66738. * Release all resources
  66739. */
  66740. dispose(): void;
  66741. private _onResize;
  66742. /** @hidden */
  66743. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  66744. /**
  66745. * Get screen coordinates for a vector3
  66746. * @param position defines the position to project
  66747. * @param worldMatrix defines the world matrix to use
  66748. * @returns the projected position
  66749. */
  66750. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  66751. private _checkUpdate;
  66752. private _clearMeasure;
  66753. private _render;
  66754. /** @hidden */
  66755. _changeCursor(cursor: string): void;
  66756. /** @hidden */
  66757. _registerLastControlDown(control: Control, pointerId: number): void;
  66758. private _doPicking;
  66759. /** @hidden */
  66760. _cleanControlAfterRemovalFromList(list: {
  66761. [pointerId: number]: Control;
  66762. }, control: Control): void;
  66763. /** @hidden */
  66764. _cleanControlAfterRemoval(control: Control): void;
  66765. /** Attach to all scene events required to support pointer events */
  66766. attach(): void;
  66767. /** @hidden */
  66768. private onClipboardCopy;
  66769. /** @hidden */
  66770. private onClipboardCut;
  66771. /** @hidden */
  66772. private onClipboardPaste;
  66773. /**
  66774. * Register the clipboard Events onto the canvas
  66775. */
  66776. registerClipboardEvents(): void;
  66777. /**
  66778. * Unregister the clipboard Events from the canvas
  66779. */
  66780. unRegisterClipboardEvents(): void;
  66781. /**
  66782. * Connect the texture to a hosting mesh to enable interactions
  66783. * @param mesh defines the mesh to attach to
  66784. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  66785. */
  66786. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  66787. /**
  66788. * Move the focus to a specific control
  66789. * @param control defines the control which will receive the focus
  66790. */
  66791. moveFocusToControl(control: IFocusableControl): void;
  66792. private _manageFocus;
  66793. private _attachToOnPointerOut;
  66794. /**
  66795. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  66796. * @param mesh defines the mesh which will receive the texture
  66797. * @param width defines the texture width (1024 by default)
  66798. * @param height defines the texture height (1024 by default)
  66799. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  66800. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  66801. * @returns a new AdvancedDynamicTexture
  66802. */
  66803. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  66804. /**
  66805. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  66806. * In this mode the texture will rely on a layer for its rendering.
  66807. * This allows it to be treated like any other layer.
  66808. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  66809. * LayerMask is set through advancedTexture.layer.layerMask
  66810. * @param name defines name for the texture
  66811. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  66812. * @param scene defines the hsoting scene
  66813. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  66814. * @returns a new AdvancedDynamicTexture
  66815. */
  66816. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  66817. }
  66818. }
  66819. declare module BABYLON.GUI {
  66820. /**
  66821. * Root class used for all 2D controls
  66822. * @see http://doc.babylonjs.com/how_to/gui#controls
  66823. */
  66824. export class Control {
  66825. /** defines the name of the control */
  66826. name?: string | undefined;
  66827. /**
  66828. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  66829. */
  66830. static AllowAlphaInheritance: boolean;
  66831. private _alpha;
  66832. private _alphaSet;
  66833. private _zIndex;
  66834. /** @hidden */
  66835. _host: AdvancedDynamicTexture;
  66836. /** Gets or sets the control parent */
  66837. parent: BABYLON.Nullable<Container>;
  66838. /** @hidden */
  66839. _currentMeasure: Measure;
  66840. private _fontFamily;
  66841. private _fontStyle;
  66842. private _fontWeight;
  66843. private _fontSize;
  66844. private _font;
  66845. /** @hidden */
  66846. _width: ValueAndUnit;
  66847. /** @hidden */
  66848. _height: ValueAndUnit;
  66849. /** @hidden */
  66850. protected _fontOffset: {
  66851. ascent: number;
  66852. height: number;
  66853. descent: number;
  66854. };
  66855. private _color;
  66856. private _style;
  66857. private _styleObserver;
  66858. /** @hidden */
  66859. protected _horizontalAlignment: number;
  66860. /** @hidden */
  66861. protected _verticalAlignment: number;
  66862. /** @hidden */
  66863. protected _isDirty: boolean;
  66864. /** @hidden */
  66865. protected _wasDirty: boolean;
  66866. /** @hidden */
  66867. _tempParentMeasure: Measure;
  66868. /** @hidden */
  66869. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  66870. /** @hidden */
  66871. protected _cachedParentMeasure: Measure;
  66872. private _paddingLeft;
  66873. private _paddingRight;
  66874. private _paddingTop;
  66875. private _paddingBottom;
  66876. /** @hidden */
  66877. _left: ValueAndUnit;
  66878. /** @hidden */
  66879. _top: ValueAndUnit;
  66880. private _scaleX;
  66881. private _scaleY;
  66882. private _rotation;
  66883. private _transformCenterX;
  66884. private _transformCenterY;
  66885. /** @hidden */
  66886. _transformMatrix: Matrix2D;
  66887. /** @hidden */
  66888. protected _invertTransformMatrix: Matrix2D;
  66889. /** @hidden */
  66890. protected _transformedPosition: BABYLON.Vector2;
  66891. private _isMatrixDirty;
  66892. private _cachedOffsetX;
  66893. private _cachedOffsetY;
  66894. private _isVisible;
  66895. private _isHighlighted;
  66896. /** @hidden */
  66897. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66898. private _fontSet;
  66899. private _dummyVector2;
  66900. private _downCount;
  66901. private _enterCount;
  66902. private _doNotRender;
  66903. private _downPointerIds;
  66904. protected _isEnabled: boolean;
  66905. protected _disabledColor: string;
  66906. /** @hidden */
  66907. protected _rebuildLayout: boolean;
  66908. /** @hidden */
  66909. _isClipped: boolean;
  66910. /** @hidden */
  66911. _automaticSize: boolean;
  66912. /** @hidden */
  66913. _tag: any;
  66914. /**
  66915. * 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
  66916. */
  66917. uniqueId: number;
  66918. /**
  66919. * Gets or sets an object used to store user defined information for the node
  66920. */
  66921. metadata: any;
  66922. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  66923. isHitTestVisible: boolean;
  66924. /** Gets or sets a boolean indicating if the control can block pointer events */
  66925. isPointerBlocker: boolean;
  66926. /** Gets or sets a boolean indicating if the control can be focusable */
  66927. isFocusInvisible: boolean;
  66928. /**
  66929. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  66930. * 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
  66931. */
  66932. clipChildren: boolean;
  66933. /**
  66934. * Gets or sets a boolean indicating that control content must be clipped
  66935. * 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
  66936. */
  66937. clipContent: boolean;
  66938. /**
  66939. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  66940. */
  66941. useBitmapCache: boolean;
  66942. private _cacheData;
  66943. private _shadowOffsetX;
  66944. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  66945. shadowOffsetX: number;
  66946. private _shadowOffsetY;
  66947. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  66948. shadowOffsetY: number;
  66949. private _shadowBlur;
  66950. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  66951. shadowBlur: number;
  66952. private _shadowColor;
  66953. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  66954. shadowColor: string;
  66955. /** Gets or sets the cursor to use when the control is hovered */
  66956. hoverCursor: string;
  66957. /** @hidden */
  66958. protected _linkOffsetX: ValueAndUnit;
  66959. /** @hidden */
  66960. protected _linkOffsetY: ValueAndUnit;
  66961. /** Gets the control type name */
  66962. readonly typeName: string;
  66963. /**
  66964. * Get the current class name of the control.
  66965. * @returns current class name
  66966. */
  66967. getClassName(): string;
  66968. /**
  66969. * An event triggered when the pointer move over the control.
  66970. */
  66971. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  66972. /**
  66973. * An event triggered when the pointer move out of the control.
  66974. */
  66975. onPointerOutObservable: BABYLON.Observable<Control>;
  66976. /**
  66977. * An event triggered when the pointer taps the control
  66978. */
  66979. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  66980. /**
  66981. * An event triggered when pointer up
  66982. */
  66983. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  66984. /**
  66985. * An event triggered when a control is clicked on
  66986. */
  66987. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  66988. /**
  66989. * An event triggered when pointer enters the control
  66990. */
  66991. onPointerEnterObservable: BABYLON.Observable<Control>;
  66992. /**
  66993. * An event triggered when the control is marked as dirty
  66994. */
  66995. onDirtyObservable: BABYLON.Observable<Control>;
  66996. /**
  66997. * An event triggered before drawing the control
  66998. */
  66999. onBeforeDrawObservable: BABYLON.Observable<Control>;
  67000. /**
  67001. * An event triggered after the control was drawn
  67002. */
  67003. onAfterDrawObservable: BABYLON.Observable<Control>;
  67004. /**
  67005. * Get the hosting AdvancedDynamicTexture
  67006. */
  67007. readonly host: AdvancedDynamicTexture;
  67008. /** Gets or set information about font offsets (used to render and align text) */
  67009. fontOffset: {
  67010. ascent: number;
  67011. height: number;
  67012. descent: number;
  67013. };
  67014. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  67015. alpha: number;
  67016. /**
  67017. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  67018. */
  67019. isHighlighted: boolean;
  67020. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  67021. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  67022. */
  67023. scaleX: number;
  67024. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  67025. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  67026. */
  67027. scaleY: number;
  67028. /** Gets or sets the rotation angle (0 by default)
  67029. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  67030. */
  67031. rotation: number;
  67032. /** Gets or sets the transformation center on Y axis (0 by default)
  67033. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  67034. */
  67035. transformCenterY: number;
  67036. /** Gets or sets the transformation center on X axis (0 by default)
  67037. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  67038. */
  67039. transformCenterX: number;
  67040. /**
  67041. * Gets or sets the horizontal alignment
  67042. * @see http://doc.babylonjs.com/how_to/gui#alignments
  67043. */
  67044. horizontalAlignment: number;
  67045. /**
  67046. * Gets or sets the vertical alignment
  67047. * @see http://doc.babylonjs.com/how_to/gui#alignments
  67048. */
  67049. verticalAlignment: number;
  67050. /**
  67051. * Gets or sets control width
  67052. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67053. */
  67054. width: string | number;
  67055. /**
  67056. * Gets or sets the control width in pixel
  67057. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67058. */
  67059. widthInPixels: number;
  67060. /**
  67061. * Gets or sets control height
  67062. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67063. */
  67064. height: string | number;
  67065. /**
  67066. * Gets or sets control height in pixel
  67067. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67068. */
  67069. heightInPixels: number;
  67070. /** Gets or set font family */
  67071. fontFamily: string;
  67072. /** Gets or sets font style */
  67073. fontStyle: string;
  67074. /** Gets or sets font weight */
  67075. fontWeight: string;
  67076. /**
  67077. * Gets or sets style
  67078. * @see http://doc.babylonjs.com/how_to/gui#styles
  67079. */
  67080. style: BABYLON.Nullable<Style>;
  67081. /** @hidden */
  67082. readonly _isFontSizeInPercentage: boolean;
  67083. /** Gets or sets font size in pixels */
  67084. fontSizeInPixels: number;
  67085. /** Gets or sets font size */
  67086. fontSize: string | number;
  67087. /** Gets or sets foreground color */
  67088. color: string;
  67089. /** Gets or sets z index which is used to reorder controls on the z axis */
  67090. zIndex: number;
  67091. /** Gets or sets a boolean indicating if the control can be rendered */
  67092. notRenderable: boolean;
  67093. /** Gets or sets a boolean indicating if the control is visible */
  67094. isVisible: boolean;
  67095. /** Gets a boolean indicating that the control needs to update its rendering */
  67096. readonly isDirty: boolean;
  67097. /**
  67098. * Gets the current linked mesh (or null if none)
  67099. */
  67100. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  67101. /**
  67102. * Gets or sets a value indicating the padding to use on the left of the control
  67103. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67104. */
  67105. paddingLeft: string | number;
  67106. /**
  67107. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  67108. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67109. */
  67110. paddingLeftInPixels: number;
  67111. /**
  67112. * Gets or sets a value indicating the padding to use on the right of the control
  67113. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67114. */
  67115. paddingRight: string | number;
  67116. /**
  67117. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  67118. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67119. */
  67120. paddingRightInPixels: number;
  67121. /**
  67122. * Gets or sets a value indicating the padding to use on the top of the control
  67123. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67124. */
  67125. paddingTop: string | number;
  67126. /**
  67127. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  67128. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67129. */
  67130. paddingTopInPixels: number;
  67131. /**
  67132. * Gets or sets a value indicating the padding to use on the bottom of the control
  67133. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67134. */
  67135. paddingBottom: string | number;
  67136. /**
  67137. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  67138. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67139. */
  67140. paddingBottomInPixels: number;
  67141. /**
  67142. * Gets or sets a value indicating the left coordinate of the control
  67143. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67144. */
  67145. left: string | number;
  67146. /**
  67147. * Gets or sets a value indicating the left coordinate in pixels of the control
  67148. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67149. */
  67150. leftInPixels: number;
  67151. /**
  67152. * Gets or sets a value indicating the top coordinate of the control
  67153. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67154. */
  67155. top: string | number;
  67156. /**
  67157. * Gets or sets a value indicating the top coordinate in pixels of the control
  67158. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67159. */
  67160. topInPixels: number;
  67161. /**
  67162. * Gets or sets a value indicating the offset on X axis to the linked mesh
  67163. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  67164. */
  67165. linkOffsetX: string | number;
  67166. /**
  67167. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  67168. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  67169. */
  67170. linkOffsetXInPixels: number;
  67171. /**
  67172. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  67173. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  67174. */
  67175. linkOffsetY: string | number;
  67176. /**
  67177. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  67178. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  67179. */
  67180. linkOffsetYInPixels: number;
  67181. /** Gets the center coordinate on X axis */
  67182. readonly centerX: number;
  67183. /** Gets the center coordinate on Y axis */
  67184. readonly centerY: number;
  67185. /** Gets or sets if control is Enabled*/
  67186. isEnabled: boolean;
  67187. /** Gets or sets background color of control if it's disabled*/
  67188. disabledColor: string;
  67189. /**
  67190. * Creates a new control
  67191. * @param name defines the name of the control
  67192. */
  67193. constructor(
  67194. /** defines the name of the control */
  67195. name?: string | undefined);
  67196. /** @hidden */
  67197. protected _getTypeName(): string;
  67198. /**
  67199. * Gets the first ascendant in the hierarchy of the given type
  67200. * @param className defines the required type
  67201. * @returns the ascendant or null if not found
  67202. */
  67203. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  67204. /** @hidden */
  67205. _resetFontCache(): void;
  67206. /**
  67207. * Determines if a container is an ascendant of the current control
  67208. * @param container defines the container to look for
  67209. * @returns true if the container is one of the ascendant of the control
  67210. */
  67211. isAscendant(container: Control): boolean;
  67212. /**
  67213. * Gets coordinates in local control space
  67214. * @param globalCoordinates defines the coordinates to transform
  67215. * @returns the new coordinates in local space
  67216. */
  67217. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  67218. /**
  67219. * Gets coordinates in local control space
  67220. * @param globalCoordinates defines the coordinates to transform
  67221. * @param result defines the target vector2 where to store the result
  67222. * @returns the current control
  67223. */
  67224. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  67225. /**
  67226. * Gets coordinates in parent local control space
  67227. * @param globalCoordinates defines the coordinates to transform
  67228. * @returns the new coordinates in parent local space
  67229. */
  67230. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  67231. /**
  67232. * Move the current control to a vector3 position projected onto the screen.
  67233. * @param position defines the target position
  67234. * @param scene defines the hosting scene
  67235. */
  67236. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  67237. /**
  67238. * Will store all controls that have this control as ascendant in a given array
  67239. * @param results defines the array where to store the descendants
  67240. * @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
  67241. * @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
  67242. */
  67243. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  67244. /**
  67245. * Will return all controls that have this control as ascendant
  67246. * @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
  67247. * @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
  67248. * @return all child controls
  67249. */
  67250. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  67251. /**
  67252. * Link current control with a target mesh
  67253. * @param mesh defines the mesh to link with
  67254. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  67255. */
  67256. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  67257. /** @hidden */
  67258. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  67259. /** @hidden */
  67260. _offsetLeft(offset: number): void;
  67261. /** @hidden */
  67262. _offsetTop(offset: number): void;
  67263. /** @hidden */
  67264. _markMatrixAsDirty(): void;
  67265. /** @hidden */
  67266. _flagDescendantsAsMatrixDirty(): void;
  67267. /** @hidden */
  67268. _intersectsRect(rect: Measure): boolean;
  67269. /** @hidden */
  67270. protected invalidateRect(): void;
  67271. /** @hidden */
  67272. _markAsDirty(force?: boolean): void;
  67273. /** @hidden */
  67274. _markAllAsDirty(): void;
  67275. /** @hidden */
  67276. _link(host: AdvancedDynamicTexture): void;
  67277. /** @hidden */
  67278. protected _transform(context?: CanvasRenderingContext2D): void;
  67279. /** @hidden */
  67280. _renderHighlight(context: CanvasRenderingContext2D): void;
  67281. /** @hidden */
  67282. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  67283. /** @hidden */
  67284. protected _applyStates(context: CanvasRenderingContext2D): void;
  67285. /** @hidden */
  67286. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  67287. /** @hidden */
  67288. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67289. protected _evaluateClippingState(parentMeasure: Measure): void;
  67290. /** @hidden */
  67291. _measure(): void;
  67292. /** @hidden */
  67293. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67294. /** @hidden */
  67295. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67296. /** @hidden */
  67297. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67298. /** @hidden */
  67299. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  67300. private static _ClipMeasure;
  67301. private _tmpMeasureA;
  67302. private _clip;
  67303. /** @hidden */
  67304. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  67305. /** @hidden */
  67306. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  67307. /**
  67308. * Tests if a given coordinates belong to the current control
  67309. * @param x defines x coordinate to test
  67310. * @param y defines y coordinate to test
  67311. * @returns true if the coordinates are inside the control
  67312. */
  67313. contains(x: number, y: number): boolean;
  67314. /** @hidden */
  67315. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  67316. /** @hidden */
  67317. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  67318. /** @hidden */
  67319. _onPointerEnter(target: Control): boolean;
  67320. /** @hidden */
  67321. _onPointerOut(target: Control, force?: boolean): void;
  67322. /** @hidden */
  67323. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67324. /** @hidden */
  67325. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67326. /** @hidden */
  67327. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  67328. /** @hidden */
  67329. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  67330. private _prepareFont;
  67331. /** Releases associated resources */
  67332. dispose(): void;
  67333. private static _HORIZONTAL_ALIGNMENT_LEFT;
  67334. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  67335. private static _HORIZONTAL_ALIGNMENT_CENTER;
  67336. private static _VERTICAL_ALIGNMENT_TOP;
  67337. private static _VERTICAL_ALIGNMENT_BOTTOM;
  67338. private static _VERTICAL_ALIGNMENT_CENTER;
  67339. /** HORIZONTAL_ALIGNMENT_LEFT */
  67340. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  67341. /** HORIZONTAL_ALIGNMENT_RIGHT */
  67342. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  67343. /** HORIZONTAL_ALIGNMENT_CENTER */
  67344. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  67345. /** VERTICAL_ALIGNMENT_TOP */
  67346. static readonly VERTICAL_ALIGNMENT_TOP: number;
  67347. /** VERTICAL_ALIGNMENT_BOTTOM */
  67348. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  67349. /** VERTICAL_ALIGNMENT_CENTER */
  67350. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  67351. private static _FontHeightSizes;
  67352. /** @hidden */
  67353. static _GetFontOffset(font: string): {
  67354. ascent: number;
  67355. height: number;
  67356. descent: number;
  67357. };
  67358. /**
  67359. * Creates a stack panel that can be used to render headers
  67360. * @param control defines the control to associate with the header
  67361. * @param text defines the text of the header
  67362. * @param size defines the size of the header
  67363. * @param options defines options used to configure the header
  67364. * @returns a new StackPanel
  67365. * @ignore
  67366. * @hidden
  67367. */
  67368. static AddHeader: (control: Control, text: string, size: string | number, options: {
  67369. isHorizontal: boolean;
  67370. controlFirst: boolean;
  67371. }) => any;
  67372. /** @hidden */
  67373. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  67374. }
  67375. }
  67376. declare module BABYLON.GUI {
  67377. /**
  67378. * Root class for 2D containers
  67379. * @see http://doc.babylonjs.com/how_to/gui#containers
  67380. */
  67381. export class Container extends Control {
  67382. name?: string | undefined;
  67383. /** @hidden */
  67384. protected _children: Control[];
  67385. /** @hidden */
  67386. protected _measureForChildren: Measure;
  67387. /** @hidden */
  67388. protected _background: string;
  67389. /** @hidden */
  67390. protected _adaptWidthToChildren: boolean;
  67391. /** @hidden */
  67392. protected _adaptHeightToChildren: boolean;
  67393. /**
  67394. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  67395. */
  67396. logLayoutCycleErrors: boolean;
  67397. /**
  67398. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  67399. */
  67400. maxLayoutCycle: number;
  67401. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  67402. adaptHeightToChildren: boolean;
  67403. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  67404. adaptWidthToChildren: boolean;
  67405. /** Gets or sets background color */
  67406. background: string;
  67407. /** Gets the list of children */
  67408. readonly children: Control[];
  67409. /**
  67410. * Creates a new Container
  67411. * @param name defines the name of the container
  67412. */
  67413. constructor(name?: string | undefined);
  67414. protected _getTypeName(): string;
  67415. _flagDescendantsAsMatrixDirty(): void;
  67416. /**
  67417. * Gets a child using its name
  67418. * @param name defines the child name to look for
  67419. * @returns the child control if found
  67420. */
  67421. getChildByName(name: string): BABYLON.Nullable<Control>;
  67422. /**
  67423. * Gets a child using its type and its name
  67424. * @param name defines the child name to look for
  67425. * @param type defines the child type to look for
  67426. * @returns the child control if found
  67427. */
  67428. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  67429. /**
  67430. * Search for a specific control in children
  67431. * @param control defines the control to look for
  67432. * @returns true if the control is in child list
  67433. */
  67434. containsControl(control: Control): boolean;
  67435. /**
  67436. * Adds a new control to the current container
  67437. * @param control defines the control to add
  67438. * @returns the current container
  67439. */
  67440. addControl(control: BABYLON.Nullable<Control>): Container;
  67441. /**
  67442. * Removes all controls from the current container
  67443. * @returns the current container
  67444. */
  67445. clearControls(): Container;
  67446. /**
  67447. * Removes a control from the current container
  67448. * @param control defines the control to remove
  67449. * @returns the current container
  67450. */
  67451. removeControl(control: Control): Container;
  67452. /** @hidden */
  67453. _reOrderControl(control: Control): void;
  67454. /** @hidden */
  67455. _offsetLeft(offset: number): void;
  67456. /** @hidden */
  67457. _offsetTop(offset: number): void;
  67458. /** @hidden */
  67459. _markAllAsDirty(): void;
  67460. /** @hidden */
  67461. protected _localDraw(context: CanvasRenderingContext2D): void;
  67462. /** @hidden */
  67463. _link(host: AdvancedDynamicTexture): void;
  67464. /** @hidden */
  67465. protected _beforeLayout(): void;
  67466. /** @hidden */
  67467. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67468. /** @hidden */
  67469. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  67470. protected _postMeasure(): void;
  67471. /** @hidden */
  67472. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  67473. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  67474. /** @hidden */
  67475. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  67476. /** @hidden */
  67477. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67478. /** Releases associated resources */
  67479. dispose(): void;
  67480. }
  67481. }
  67482. declare module BABYLON.GUI {
  67483. /** Class used to create rectangle container */
  67484. export class Rectangle extends Container {
  67485. name?: string | undefined;
  67486. private _thickness;
  67487. private _cornerRadius;
  67488. /** Gets or sets border thickness */
  67489. thickness: number;
  67490. /** Gets or sets the corner radius angle */
  67491. cornerRadius: number;
  67492. /**
  67493. * Creates a new Rectangle
  67494. * @param name defines the control name
  67495. */
  67496. constructor(name?: string | undefined);
  67497. protected _getTypeName(): string;
  67498. protected _localDraw(context: CanvasRenderingContext2D): void;
  67499. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67500. private _drawRoundedRect;
  67501. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  67502. }
  67503. }
  67504. declare module BABYLON.GUI {
  67505. /**
  67506. * Enum that determines the text-wrapping mode to use.
  67507. */
  67508. export enum TextWrapping {
  67509. /**
  67510. * Clip the text when it's larger than Control.width; this is the default mode.
  67511. */
  67512. Clip = 0,
  67513. /**
  67514. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  67515. */
  67516. WordWrap = 1,
  67517. /**
  67518. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  67519. */
  67520. Ellipsis = 2
  67521. }
  67522. /**
  67523. * Class used to create text block control
  67524. */
  67525. export class TextBlock extends Control {
  67526. /**
  67527. * Defines the name of the control
  67528. */
  67529. name?: string | undefined;
  67530. private _text;
  67531. private _textWrapping;
  67532. private _textHorizontalAlignment;
  67533. private _textVerticalAlignment;
  67534. private _lines;
  67535. private _resizeToFit;
  67536. private _lineSpacing;
  67537. private _outlineWidth;
  67538. private _outlineColor;
  67539. /**
  67540. * An event triggered after the text is changed
  67541. */
  67542. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  67543. /**
  67544. * An event triggered after the text was broken up into lines
  67545. */
  67546. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  67547. /**
  67548. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  67549. */
  67550. readonly lines: any[];
  67551. /**
  67552. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  67553. */
  67554. /**
  67555. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  67556. */
  67557. resizeToFit: boolean;
  67558. /**
  67559. * Gets or sets a boolean indicating if text must be wrapped
  67560. */
  67561. /**
  67562. * Gets or sets a boolean indicating if text must be wrapped
  67563. */
  67564. textWrapping: TextWrapping | boolean;
  67565. /**
  67566. * Gets or sets text to display
  67567. */
  67568. /**
  67569. * Gets or sets text to display
  67570. */
  67571. text: string;
  67572. /**
  67573. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  67574. */
  67575. /**
  67576. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  67577. */
  67578. textHorizontalAlignment: number;
  67579. /**
  67580. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  67581. */
  67582. /**
  67583. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  67584. */
  67585. textVerticalAlignment: number;
  67586. /**
  67587. * Gets or sets line spacing value
  67588. */
  67589. /**
  67590. * Gets or sets line spacing value
  67591. */
  67592. lineSpacing: string | number;
  67593. /**
  67594. * Gets or sets outlineWidth of the text to display
  67595. */
  67596. /**
  67597. * Gets or sets outlineWidth of the text to display
  67598. */
  67599. outlineWidth: number;
  67600. /**
  67601. * Gets or sets outlineColor of the text to display
  67602. */
  67603. /**
  67604. * Gets or sets outlineColor of the text to display
  67605. */
  67606. outlineColor: string;
  67607. /**
  67608. * Creates a new TextBlock object
  67609. * @param name defines the name of the control
  67610. * @param text defines the text to display (emptry string by default)
  67611. */
  67612. constructor(
  67613. /**
  67614. * Defines the name of the control
  67615. */
  67616. name?: string | undefined, text?: string);
  67617. protected _getTypeName(): string;
  67618. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67619. private _drawText;
  67620. /** @hidden */
  67621. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  67622. protected _applyStates(context: CanvasRenderingContext2D): void;
  67623. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  67624. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  67625. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  67626. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  67627. protected _renderLines(context: CanvasRenderingContext2D): void;
  67628. /**
  67629. * Given a width constraint applied on the text block, find the expected height
  67630. * @returns expected height
  67631. */
  67632. computeExpectedHeight(): number;
  67633. dispose(): void;
  67634. }
  67635. }
  67636. declare module BABYLON.GUI {
  67637. /**
  67638. * Class used to create 2D images
  67639. */
  67640. export class Image extends Control {
  67641. name?: string | undefined;
  67642. private _workingCanvas;
  67643. private _domImage;
  67644. private _imageWidth;
  67645. private _imageHeight;
  67646. private _loaded;
  67647. private _stretch;
  67648. private _source;
  67649. private _autoScale;
  67650. private _sourceLeft;
  67651. private _sourceTop;
  67652. private _sourceWidth;
  67653. private _sourceHeight;
  67654. private _cellWidth;
  67655. private _cellHeight;
  67656. private _cellId;
  67657. private _populateNinePatchSlicesFromImage;
  67658. private _sliceLeft;
  67659. private _sliceRight;
  67660. private _sliceTop;
  67661. private _sliceBottom;
  67662. private _detectPointerOnOpaqueOnly;
  67663. /**
  67664. * BABYLON.Observable notified when the content is loaded
  67665. */
  67666. onImageLoadedObservable: BABYLON.Observable<Image>;
  67667. /**
  67668. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  67669. */
  67670. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  67671. /**
  67672. * Gets a boolean indicating that the content is loaded
  67673. */
  67674. readonly isLoaded: boolean;
  67675. /**
  67676. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  67677. */
  67678. populateNinePatchSlicesFromImage: boolean;
  67679. /**
  67680. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  67681. * Beware using this as this will comsume more memory as the image has to be stored twice
  67682. */
  67683. detectPointerOnOpaqueOnly: boolean;
  67684. /**
  67685. * Gets or sets the left value for slicing (9-patch)
  67686. */
  67687. sliceLeft: number;
  67688. /**
  67689. * Gets or sets the right value for slicing (9-patch)
  67690. */
  67691. sliceRight: number;
  67692. /**
  67693. * Gets or sets the top value for slicing (9-patch)
  67694. */
  67695. sliceTop: number;
  67696. /**
  67697. * Gets or sets the bottom value for slicing (9-patch)
  67698. */
  67699. sliceBottom: number;
  67700. /**
  67701. * Gets or sets the left coordinate in the source image
  67702. */
  67703. sourceLeft: number;
  67704. /**
  67705. * Gets or sets the top coordinate in the source image
  67706. */
  67707. sourceTop: number;
  67708. /**
  67709. * Gets or sets the width to capture in the source image
  67710. */
  67711. sourceWidth: number;
  67712. /**
  67713. * Gets or sets the height to capture in the source image
  67714. */
  67715. sourceHeight: number;
  67716. /**
  67717. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  67718. * @see http://doc.babylonjs.com/how_to/gui#image
  67719. */
  67720. autoScale: boolean;
  67721. /** Gets or sets the streching mode used by the image */
  67722. stretch: number;
  67723. /** @hidden */
  67724. _rotate90(n: number): Image;
  67725. /**
  67726. * Gets or sets the internal DOM image used to render the control
  67727. */
  67728. domImage: HTMLImageElement;
  67729. private _onImageLoaded;
  67730. private _extractNinePatchSliceDataFromImage;
  67731. /**
  67732. * Gets or sets image source url
  67733. */
  67734. source: BABYLON.Nullable<string>;
  67735. /**
  67736. * Checks for svg document with icon id present
  67737. */
  67738. private _svgCheck;
  67739. /**
  67740. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  67741. * given external svg file and icon id
  67742. */
  67743. private _getSVGAttribs;
  67744. /**
  67745. * Gets or sets the cell width to use when animation sheet is enabled
  67746. * @see http://doc.babylonjs.com/how_to/gui#image
  67747. */
  67748. cellWidth: number;
  67749. /**
  67750. * Gets or sets the cell height to use when animation sheet is enabled
  67751. * @see http://doc.babylonjs.com/how_to/gui#image
  67752. */
  67753. cellHeight: number;
  67754. /**
  67755. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  67756. * @see http://doc.babylonjs.com/how_to/gui#image
  67757. */
  67758. cellId: number;
  67759. /**
  67760. * Creates a new Image
  67761. * @param name defines the control name
  67762. * @param url defines the image url
  67763. */
  67764. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  67765. /**
  67766. * Tests if a given coordinates belong to the current control
  67767. * @param x defines x coordinate to test
  67768. * @param y defines y coordinate to test
  67769. * @returns true if the coordinates are inside the control
  67770. */
  67771. contains(x: number, y: number): boolean;
  67772. protected _getTypeName(): string;
  67773. /** Force the control to synchronize with its content */
  67774. synchronizeSizeWithContent(): void;
  67775. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67776. private _prepareWorkingCanvasForOpaqueDetection;
  67777. private _drawImage;
  67778. _draw(context: CanvasRenderingContext2D): void;
  67779. private _renderCornerPatch;
  67780. private _renderNinePatch;
  67781. dispose(): void;
  67782. /** STRETCH_NONE */
  67783. static readonly STRETCH_NONE: number;
  67784. /** STRETCH_FILL */
  67785. static readonly STRETCH_FILL: number;
  67786. /** STRETCH_UNIFORM */
  67787. static readonly STRETCH_UNIFORM: number;
  67788. /** STRETCH_EXTEND */
  67789. static readonly STRETCH_EXTEND: number;
  67790. /** NINE_PATCH */
  67791. static readonly STRETCH_NINE_PATCH: number;
  67792. }
  67793. }
  67794. declare module BABYLON.GUI {
  67795. /**
  67796. * Class used to create 2D buttons
  67797. */
  67798. export class Button extends Rectangle {
  67799. name?: string | undefined;
  67800. /**
  67801. * Function called to generate a pointer enter animation
  67802. */
  67803. pointerEnterAnimation: () => void;
  67804. /**
  67805. * Function called to generate a pointer out animation
  67806. */
  67807. pointerOutAnimation: () => void;
  67808. /**
  67809. * Function called to generate a pointer down animation
  67810. */
  67811. pointerDownAnimation: () => void;
  67812. /**
  67813. * Function called to generate a pointer up animation
  67814. */
  67815. pointerUpAnimation: () => void;
  67816. /**
  67817. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  67818. */
  67819. delegatePickingToChildren: boolean;
  67820. private _image;
  67821. /**
  67822. * Returns the image part of the button (if any)
  67823. */
  67824. readonly image: BABYLON.Nullable<Image>;
  67825. private _textBlock;
  67826. /**
  67827. * Returns the image part of the button (if any)
  67828. */
  67829. readonly textBlock: BABYLON.Nullable<TextBlock>;
  67830. /**
  67831. * Creates a new Button
  67832. * @param name defines the name of the button
  67833. */
  67834. constructor(name?: string | undefined);
  67835. protected _getTypeName(): string;
  67836. /** @hidden */
  67837. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  67838. /** @hidden */
  67839. _onPointerEnter(target: Control): boolean;
  67840. /** @hidden */
  67841. _onPointerOut(target: Control, force?: boolean): void;
  67842. /** @hidden */
  67843. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67844. /** @hidden */
  67845. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67846. /**
  67847. * Creates a new button made with an image and a text
  67848. * @param name defines the name of the button
  67849. * @param text defines the text of the button
  67850. * @param imageUrl defines the url of the image
  67851. * @returns a new Button
  67852. */
  67853. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  67854. /**
  67855. * Creates a new button made with an image
  67856. * @param name defines the name of the button
  67857. * @param imageUrl defines the url of the image
  67858. * @returns a new Button
  67859. */
  67860. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  67861. /**
  67862. * Creates a new button made with a text
  67863. * @param name defines the name of the button
  67864. * @param text defines the text of the button
  67865. * @returns a new Button
  67866. */
  67867. static CreateSimpleButton(name: string, text: string): Button;
  67868. /**
  67869. * Creates a new button made with an image and a centered text
  67870. * @param name defines the name of the button
  67871. * @param text defines the text of the button
  67872. * @param imageUrl defines the url of the image
  67873. * @returns a new Button
  67874. */
  67875. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  67876. }
  67877. }
  67878. declare module BABYLON.GUI {
  67879. /**
  67880. * Class used to create a 2D stack panel container
  67881. */
  67882. export class StackPanel extends Container {
  67883. name?: string | undefined;
  67884. private _isVertical;
  67885. private _manualWidth;
  67886. private _manualHeight;
  67887. private _doNotTrackManualChanges;
  67888. /**
  67889. * Gets or sets a boolean indicating that layou warnings should be ignored
  67890. */
  67891. ignoreLayoutWarnings: boolean;
  67892. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  67893. isVertical: boolean;
  67894. /**
  67895. * Gets or sets panel width.
  67896. * This value should not be set when in horizontal mode as it will be computed automatically
  67897. */
  67898. width: string | number;
  67899. /**
  67900. * Gets or sets panel height.
  67901. * This value should not be set when in vertical mode as it will be computed automatically
  67902. */
  67903. height: string | number;
  67904. /**
  67905. * Creates a new StackPanel
  67906. * @param name defines control name
  67907. */
  67908. constructor(name?: string | undefined);
  67909. protected _getTypeName(): string;
  67910. /** @hidden */
  67911. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67912. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67913. protected _postMeasure(): void;
  67914. }
  67915. }
  67916. declare module BABYLON.GUI {
  67917. /**
  67918. * Class used to represent a 2D checkbox
  67919. */
  67920. export class Checkbox extends Control {
  67921. name?: string | undefined;
  67922. private _isChecked;
  67923. private _background;
  67924. private _checkSizeRatio;
  67925. private _thickness;
  67926. /** Gets or sets border thickness */
  67927. thickness: number;
  67928. /**
  67929. * BABYLON.Observable raised when isChecked property changes
  67930. */
  67931. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  67932. /** Gets or sets a value indicating the ratio between overall size and check size */
  67933. checkSizeRatio: number;
  67934. /** Gets or sets background color */
  67935. background: string;
  67936. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  67937. isChecked: boolean;
  67938. /**
  67939. * Creates a new CheckBox
  67940. * @param name defines the control name
  67941. */
  67942. constructor(name?: string | undefined);
  67943. protected _getTypeName(): string;
  67944. /** @hidden */
  67945. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  67946. /** @hidden */
  67947. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67948. /**
  67949. * Utility function to easily create a checkbox with a header
  67950. * @param title defines the label to use for the header
  67951. * @param onValueChanged defines the callback to call when value changes
  67952. * @returns a StackPanel containing the checkbox and a textBlock
  67953. */
  67954. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  67955. }
  67956. }
  67957. declare module BABYLON.GUI {
  67958. /**
  67959. * Class used to store key control properties
  67960. */
  67961. export class KeyPropertySet {
  67962. /** Width */
  67963. width?: string;
  67964. /** Height */
  67965. height?: string;
  67966. /** Left padding */
  67967. paddingLeft?: string;
  67968. /** Right padding */
  67969. paddingRight?: string;
  67970. /** Top padding */
  67971. paddingTop?: string;
  67972. /** Bottom padding */
  67973. paddingBottom?: string;
  67974. /** Foreground color */
  67975. color?: string;
  67976. /** Background color */
  67977. background?: string;
  67978. }
  67979. /**
  67980. * Class used to create virtual keyboard
  67981. */
  67982. export class VirtualKeyboard extends StackPanel {
  67983. /** BABYLON.Observable raised when a key is pressed */
  67984. onKeyPressObservable: BABYLON.Observable<string>;
  67985. /** Gets or sets default key button width */
  67986. defaultButtonWidth: string;
  67987. /** Gets or sets default key button height */
  67988. defaultButtonHeight: string;
  67989. /** Gets or sets default key button left padding */
  67990. defaultButtonPaddingLeft: string;
  67991. /** Gets or sets default key button right padding */
  67992. defaultButtonPaddingRight: string;
  67993. /** Gets or sets default key button top padding */
  67994. defaultButtonPaddingTop: string;
  67995. /** Gets or sets default key button bottom padding */
  67996. defaultButtonPaddingBottom: string;
  67997. /** Gets or sets default key button foreground color */
  67998. defaultButtonColor: string;
  67999. /** Gets or sets default key button background color */
  68000. defaultButtonBackground: string;
  68001. /** Gets or sets shift button foreground color */
  68002. shiftButtonColor: string;
  68003. /** Gets or sets shift button thickness*/
  68004. selectedShiftThickness: number;
  68005. /** Gets shift key state */
  68006. shiftState: number;
  68007. protected _getTypeName(): string;
  68008. private _createKey;
  68009. /**
  68010. * Adds a new row of keys
  68011. * @param keys defines the list of keys to add
  68012. * @param propertySets defines the associated property sets
  68013. */
  68014. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  68015. /**
  68016. * Set the shift key to a specific state
  68017. * @param shiftState defines the new shift state
  68018. */
  68019. applyShiftState(shiftState: number): void;
  68020. private _currentlyConnectedInputText;
  68021. private _connectedInputTexts;
  68022. private _onKeyPressObserver;
  68023. /** Gets the input text control currently attached to the keyboard */
  68024. readonly connectedInputText: BABYLON.Nullable<InputText>;
  68025. /**
  68026. * Connects the keyboard with an input text control
  68027. *
  68028. * @param input defines the target control
  68029. */
  68030. connect(input: InputText): void;
  68031. /**
  68032. * Disconnects the keyboard from connected InputText controls
  68033. *
  68034. * @param input optionally defines a target control, otherwise all are disconnected
  68035. */
  68036. disconnect(input?: InputText): void;
  68037. private _removeConnectedInputObservables;
  68038. /**
  68039. * Release all resources
  68040. */
  68041. dispose(): void;
  68042. /**
  68043. * Creates a new keyboard using a default layout
  68044. *
  68045. * @param name defines control name
  68046. * @returns a new VirtualKeyboard
  68047. */
  68048. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  68049. }
  68050. }
  68051. declare module BABYLON.GUI {
  68052. /**
  68053. * Class used to create input text control
  68054. */
  68055. export class InputText extends Control implements IFocusableControl {
  68056. name?: string | undefined;
  68057. private _text;
  68058. private _placeholderText;
  68059. private _background;
  68060. private _focusedBackground;
  68061. private _focusedColor;
  68062. private _placeholderColor;
  68063. private _thickness;
  68064. private _margin;
  68065. private _autoStretchWidth;
  68066. private _maxWidth;
  68067. private _isFocused;
  68068. private _blinkTimeout;
  68069. private _blinkIsEven;
  68070. private _cursorOffset;
  68071. private _scrollLeft;
  68072. private _textWidth;
  68073. private _clickedCoordinate;
  68074. private _deadKey;
  68075. private _addKey;
  68076. private _currentKey;
  68077. private _isTextHighlightOn;
  68078. private _textHighlightColor;
  68079. private _highligherOpacity;
  68080. private _highlightedText;
  68081. private _startHighlightIndex;
  68082. private _endHighlightIndex;
  68083. private _cursorIndex;
  68084. private _onFocusSelectAll;
  68085. private _isPointerDown;
  68086. private _onClipboardObserver;
  68087. private _onPointerDblTapObserver;
  68088. /** @hidden */
  68089. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  68090. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  68091. promptMessage: string;
  68092. /** Force disable prompt on mobile device */
  68093. disableMobilePrompt: boolean;
  68094. /** BABYLON.Observable raised when the text changes */
  68095. onTextChangedObservable: BABYLON.Observable<InputText>;
  68096. /** BABYLON.Observable raised just before an entered character is to be added */
  68097. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  68098. /** BABYLON.Observable raised when the control gets the focus */
  68099. onFocusObservable: BABYLON.Observable<InputText>;
  68100. /** BABYLON.Observable raised when the control loses the focus */
  68101. onBlurObservable: BABYLON.Observable<InputText>;
  68102. /**Observable raised when the text is highlighted */
  68103. onTextHighlightObservable: BABYLON.Observable<InputText>;
  68104. /**Observable raised when copy event is triggered */
  68105. onTextCopyObservable: BABYLON.Observable<InputText>;
  68106. /** BABYLON.Observable raised when cut event is triggered */
  68107. onTextCutObservable: BABYLON.Observable<InputText>;
  68108. /** BABYLON.Observable raised when paste event is triggered */
  68109. onTextPasteObservable: BABYLON.Observable<InputText>;
  68110. /** BABYLON.Observable raised when a key event was processed */
  68111. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  68112. /** Gets or sets the maximum width allowed by the control */
  68113. maxWidth: string | number;
  68114. /** Gets the maximum width allowed by the control in pixels */
  68115. readonly maxWidthInPixels: number;
  68116. /** Gets or sets the text highlighter transparency; default: 0.4 */
  68117. highligherOpacity: number;
  68118. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  68119. onFocusSelectAll: boolean;
  68120. /** Gets or sets the text hightlight color */
  68121. textHighlightColor: string;
  68122. /** Gets or sets control margin */
  68123. margin: string;
  68124. /** Gets control margin in pixels */
  68125. readonly marginInPixels: number;
  68126. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  68127. autoStretchWidth: boolean;
  68128. /** Gets or sets border thickness */
  68129. thickness: number;
  68130. /** Gets or sets the background color when focused */
  68131. focusedBackground: string;
  68132. /** Gets or sets the background color when focused */
  68133. focusedColor: string;
  68134. /** Gets or sets the background color */
  68135. background: string;
  68136. /** Gets or sets the placeholder color */
  68137. placeholderColor: string;
  68138. /** Gets or sets the text displayed when the control is empty */
  68139. placeholderText: string;
  68140. /** Gets or sets the dead key flag */
  68141. deadKey: boolean;
  68142. /** Gets or sets the highlight text */
  68143. highlightedText: string;
  68144. /** Gets or sets if the current key should be added */
  68145. addKey: boolean;
  68146. /** Gets or sets the value of the current key being entered */
  68147. currentKey: string;
  68148. /** Gets or sets the text displayed in the control */
  68149. text: string;
  68150. /** Gets or sets control width */
  68151. width: string | number;
  68152. /**
  68153. * Creates a new InputText
  68154. * @param name defines the control name
  68155. * @param text defines the text of the control
  68156. */
  68157. constructor(name?: string | undefined, text?: string);
  68158. /** @hidden */
  68159. onBlur(): void;
  68160. /** @hidden */
  68161. onFocus(): void;
  68162. protected _getTypeName(): string;
  68163. /**
  68164. * Function called to get the list of controls that should not steal the focus from this control
  68165. * @returns an array of controls
  68166. */
  68167. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  68168. /** @hidden */
  68169. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  68170. /** @hidden */
  68171. private _updateValueFromCursorIndex;
  68172. /** @hidden */
  68173. private _processDblClick;
  68174. /** @hidden */
  68175. private _selectAllText;
  68176. /**
  68177. * Handles the keyboard event
  68178. * @param evt Defines the KeyboardEvent
  68179. */
  68180. processKeyboard(evt: KeyboardEvent): void;
  68181. /** @hidden */
  68182. private _onCopyText;
  68183. /** @hidden */
  68184. private _onCutText;
  68185. /** @hidden */
  68186. private _onPasteText;
  68187. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68188. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68189. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  68190. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  68191. protected _beforeRenderText(text: string): string;
  68192. dispose(): void;
  68193. }
  68194. }
  68195. declare module BABYLON.GUI {
  68196. /**
  68197. * Class used to create a 2D grid container
  68198. */
  68199. export class Grid extends Container {
  68200. name?: string | undefined;
  68201. private _rowDefinitions;
  68202. private _columnDefinitions;
  68203. private _cells;
  68204. private _childControls;
  68205. /**
  68206. * Gets the number of columns
  68207. */
  68208. readonly columnCount: number;
  68209. /**
  68210. * Gets the number of rows
  68211. */
  68212. readonly rowCount: number;
  68213. /** Gets the list of children */
  68214. readonly children: Control[];
  68215. /** Gets the list of cells (e.g. the containers) */
  68216. readonly cells: {
  68217. [key: string]: Container;
  68218. };
  68219. /**
  68220. * Gets the definition of a specific row
  68221. * @param index defines the index of the row
  68222. * @returns the row definition
  68223. */
  68224. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  68225. /**
  68226. * Gets the definition of a specific column
  68227. * @param index defines the index of the column
  68228. * @returns the column definition
  68229. */
  68230. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  68231. /**
  68232. * Adds a new row to the grid
  68233. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  68234. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  68235. * @returns the current grid
  68236. */
  68237. addRowDefinition(height: number, isPixel?: boolean): Grid;
  68238. /**
  68239. * Adds a new column to the grid
  68240. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  68241. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  68242. * @returns the current grid
  68243. */
  68244. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  68245. /**
  68246. * Update a row definition
  68247. * @param index defines the index of the row to update
  68248. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  68249. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  68250. * @returns the current grid
  68251. */
  68252. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  68253. /**
  68254. * Update a column definition
  68255. * @param index defines the index of the column to update
  68256. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  68257. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  68258. * @returns the current grid
  68259. */
  68260. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  68261. /**
  68262. * Gets the list of children stored in a specific cell
  68263. * @param row defines the row to check
  68264. * @param column defines the column to check
  68265. * @returns the list of controls
  68266. */
  68267. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  68268. /**
  68269. * Gets a string representing the child cell info (row x column)
  68270. * @param child defines the control to get info from
  68271. * @returns a string containing the child cell info (row x column)
  68272. */
  68273. getChildCellInfo(child: Control): string;
  68274. private _removeCell;
  68275. private _offsetCell;
  68276. /**
  68277. * Remove a column definition at specified index
  68278. * @param index defines the index of the column to remove
  68279. * @returns the current grid
  68280. */
  68281. removeColumnDefinition(index: number): Grid;
  68282. /**
  68283. * Remove a row definition at specified index
  68284. * @param index defines the index of the row to remove
  68285. * @returns the current grid
  68286. */
  68287. removeRowDefinition(index: number): Grid;
  68288. /**
  68289. * Adds a new control to the current grid
  68290. * @param control defines the control to add
  68291. * @param row defines the row where to add the control (0 by default)
  68292. * @param column defines the column where to add the control (0 by default)
  68293. * @returns the current grid
  68294. */
  68295. addControl(control: Control, row?: number, column?: number): Grid;
  68296. /**
  68297. * Removes a control from the current container
  68298. * @param control defines the control to remove
  68299. * @returns the current container
  68300. */
  68301. removeControl(control: Control): Container;
  68302. /**
  68303. * Creates a new Grid
  68304. * @param name defines control name
  68305. */
  68306. constructor(name?: string | undefined);
  68307. protected _getTypeName(): string;
  68308. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  68309. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68310. _flagDescendantsAsMatrixDirty(): void;
  68311. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  68312. /** Releases associated resources */
  68313. dispose(): void;
  68314. }
  68315. }
  68316. declare module BABYLON.GUI {
  68317. /** Class used to create color pickers */
  68318. export class ColorPicker extends Control {
  68319. name?: string | undefined;
  68320. private static _Epsilon;
  68321. private _colorWheelCanvas;
  68322. private _value;
  68323. private _tmpColor;
  68324. private _pointerStartedOnSquare;
  68325. private _pointerStartedOnWheel;
  68326. private _squareLeft;
  68327. private _squareTop;
  68328. private _squareSize;
  68329. private _h;
  68330. private _s;
  68331. private _v;
  68332. private _lastPointerDownID;
  68333. /**
  68334. * BABYLON.Observable raised when the value changes
  68335. */
  68336. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  68337. /** Gets or sets the color of the color picker */
  68338. value: BABYLON.Color3;
  68339. /**
  68340. * Gets or sets control width
  68341. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68342. */
  68343. width: string | number;
  68344. /**
  68345. * Gets or sets control height
  68346. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68347. */
  68348. /** Gets or sets control height */
  68349. height: string | number;
  68350. /** Gets or sets control size */
  68351. size: string | number;
  68352. /**
  68353. * Creates a new ColorPicker
  68354. * @param name defines the control name
  68355. */
  68356. constructor(name?: string | undefined);
  68357. protected _getTypeName(): string;
  68358. /** @hidden */
  68359. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68360. private _updateSquareProps;
  68361. private _drawGradientSquare;
  68362. private _drawCircle;
  68363. private _createColorWheelCanvas;
  68364. /** @hidden */
  68365. _draw(context: CanvasRenderingContext2D): void;
  68366. private _pointerIsDown;
  68367. private _updateValueFromPointer;
  68368. private _isPointOnSquare;
  68369. private _isPointOnWheel;
  68370. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68371. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  68372. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  68373. /**
  68374. * This function expands the color picker by creating a color picker dialog with manual
  68375. * color value input and the ability to save colors into an array to be used later in
  68376. * subsequent launches of the dialogue.
  68377. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  68378. * @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.
  68379. * @returns picked color as a hex string and the saved colors array as hex strings.
  68380. */
  68381. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  68382. pickerWidth?: string;
  68383. pickerHeight?: string;
  68384. headerHeight?: string;
  68385. lastColor?: string;
  68386. swatchLimit?: number;
  68387. numSwatchesPerLine?: number;
  68388. savedColors?: Array<string>;
  68389. }): Promise<{
  68390. savedColors?: string[];
  68391. pickedColor: string;
  68392. }>;
  68393. }
  68394. }
  68395. declare module BABYLON.GUI {
  68396. /** Class used to create 2D ellipse containers */
  68397. export class Ellipse extends Container {
  68398. name?: string | undefined;
  68399. private _thickness;
  68400. /** Gets or sets border thickness */
  68401. thickness: number;
  68402. /**
  68403. * Creates a new Ellipse
  68404. * @param name defines the control name
  68405. */
  68406. constructor(name?: string | undefined);
  68407. protected _getTypeName(): string;
  68408. protected _localDraw(context: CanvasRenderingContext2D): void;
  68409. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68410. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  68411. }
  68412. }
  68413. declare module BABYLON.GUI {
  68414. /**
  68415. * Class used to create a password control
  68416. */
  68417. export class InputPassword extends InputText {
  68418. protected _beforeRenderText(text: string): string;
  68419. }
  68420. }
  68421. declare module BABYLON.GUI {
  68422. /** Class used to render 2D lines */
  68423. export class Line extends Control {
  68424. name?: string | undefined;
  68425. private _lineWidth;
  68426. private _x1;
  68427. private _y1;
  68428. private _x2;
  68429. private _y2;
  68430. private _dash;
  68431. private _connectedControl;
  68432. private _connectedControlDirtyObserver;
  68433. /** Gets or sets the dash pattern */
  68434. dash: Array<number>;
  68435. /** Gets or sets the control connected with the line end */
  68436. connectedControl: Control;
  68437. /** Gets or sets start coordinates on X axis */
  68438. x1: string | number;
  68439. /** Gets or sets start coordinates on Y axis */
  68440. y1: string | number;
  68441. /** Gets or sets end coordinates on X axis */
  68442. x2: string | number;
  68443. /** Gets or sets end coordinates on Y axis */
  68444. y2: string | number;
  68445. /** Gets or sets line width */
  68446. lineWidth: number;
  68447. /** Gets or sets horizontal alignment */
  68448. horizontalAlignment: number;
  68449. /** Gets or sets vertical alignment */
  68450. verticalAlignment: number;
  68451. private readonly _effectiveX2;
  68452. private readonly _effectiveY2;
  68453. /**
  68454. * Creates a new Line
  68455. * @param name defines the control name
  68456. */
  68457. constructor(name?: string | undefined);
  68458. protected _getTypeName(): string;
  68459. _draw(context: CanvasRenderingContext2D): void;
  68460. _measure(): void;
  68461. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68462. /**
  68463. * Move one end of the line given 3D cartesian coordinates.
  68464. * @param position Targeted world position
  68465. * @param scene BABYLON.Scene
  68466. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  68467. */
  68468. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  68469. /**
  68470. * Move one end of the line to a position in screen absolute space.
  68471. * @param projectedPosition Position in screen absolute space (X, Y)
  68472. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  68473. */
  68474. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  68475. }
  68476. }
  68477. declare module BABYLON.GUI {
  68478. /**
  68479. * Class used to store a point for a MultiLine object.
  68480. * The point can be pure 2D coordinates, a mesh or a control
  68481. */
  68482. export class MultiLinePoint {
  68483. private _multiLine;
  68484. private _x;
  68485. private _y;
  68486. private _control;
  68487. private _mesh;
  68488. private _controlObserver;
  68489. private _meshObserver;
  68490. /** @hidden */
  68491. _point: BABYLON.Vector2;
  68492. /**
  68493. * Creates a new MultiLinePoint
  68494. * @param multiLine defines the source MultiLine object
  68495. */
  68496. constructor(multiLine: MultiLine);
  68497. /** Gets or sets x coordinate */
  68498. x: string | number;
  68499. /** Gets or sets y coordinate */
  68500. y: string | number;
  68501. /** Gets or sets the control associated with this point */
  68502. control: BABYLON.Nullable<Control>;
  68503. /** Gets or sets the mesh associated with this point */
  68504. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  68505. /** Resets links */
  68506. resetLinks(): void;
  68507. /**
  68508. * Gets a translation vector
  68509. * @returns the translation vector
  68510. */
  68511. translate(): BABYLON.Vector2;
  68512. private _translatePoint;
  68513. /** Release associated resources */
  68514. dispose(): void;
  68515. }
  68516. }
  68517. declare module BABYLON.GUI {
  68518. /**
  68519. * Class used to create multi line control
  68520. */
  68521. export class MultiLine extends Control {
  68522. name?: string | undefined;
  68523. private _lineWidth;
  68524. private _dash;
  68525. private _points;
  68526. private _minX;
  68527. private _minY;
  68528. private _maxX;
  68529. private _maxY;
  68530. /**
  68531. * Creates a new MultiLine
  68532. * @param name defines the control name
  68533. */
  68534. constructor(name?: string | undefined);
  68535. /** Gets or sets dash pattern */
  68536. dash: Array<number>;
  68537. /**
  68538. * Gets point stored at specified index
  68539. * @param index defines the index to look for
  68540. * @returns the requested point if found
  68541. */
  68542. getAt(index: number): MultiLinePoint;
  68543. /** Function called when a point is updated */
  68544. onPointUpdate: () => void;
  68545. /**
  68546. * Adds new points to the point collection
  68547. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  68548. * @returns the list of created MultiLinePoint
  68549. */
  68550. add(...items: (AbstractMesh | Control | {
  68551. x: string | number;
  68552. y: string | number;
  68553. })[]): MultiLinePoint[];
  68554. /**
  68555. * Adds a new point to the point collection
  68556. * @param item defines the item (mesh, control or 2d coordiantes) to add
  68557. * @returns the created MultiLinePoint
  68558. */
  68559. push(item?: (AbstractMesh | Control | {
  68560. x: string | number;
  68561. y: string | number;
  68562. })): MultiLinePoint;
  68563. /**
  68564. * Remove a specific value or point from the active point collection
  68565. * @param value defines the value or point to remove
  68566. */
  68567. remove(value: number | MultiLinePoint): void;
  68568. /**
  68569. * Resets this object to initial state (no point)
  68570. */
  68571. reset(): void;
  68572. /**
  68573. * Resets all links
  68574. */
  68575. resetLinks(): void;
  68576. /** Gets or sets line width */
  68577. lineWidth: number;
  68578. horizontalAlignment: number;
  68579. verticalAlignment: number;
  68580. protected _getTypeName(): string;
  68581. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68582. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68583. _measure(): void;
  68584. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68585. dispose(): void;
  68586. }
  68587. }
  68588. declare module BABYLON.GUI {
  68589. /**
  68590. * Class used to create radio button controls
  68591. */
  68592. export class RadioButton extends Control {
  68593. name?: string | undefined;
  68594. private _isChecked;
  68595. private _background;
  68596. private _checkSizeRatio;
  68597. private _thickness;
  68598. /** Gets or sets border thickness */
  68599. thickness: number;
  68600. /** Gets or sets group name */
  68601. group: string;
  68602. /** BABYLON.Observable raised when isChecked is changed */
  68603. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  68604. /** Gets or sets a value indicating the ratio between overall size and check size */
  68605. checkSizeRatio: number;
  68606. /** Gets or sets background color */
  68607. background: string;
  68608. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  68609. isChecked: boolean;
  68610. /**
  68611. * Creates a new RadioButton
  68612. * @param name defines the control name
  68613. */
  68614. constructor(name?: string | undefined);
  68615. protected _getTypeName(): string;
  68616. _draw(context: CanvasRenderingContext2D): void;
  68617. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68618. /**
  68619. * Utility function to easily create a radio button with a header
  68620. * @param title defines the label to use for the header
  68621. * @param group defines the group to use for the radio button
  68622. * @param isChecked defines the initial state of the radio button
  68623. * @param onValueChanged defines the callback to call when value changes
  68624. * @returns a StackPanel containing the radio button and a textBlock
  68625. */
  68626. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  68627. }
  68628. }
  68629. declare module BABYLON.GUI {
  68630. /**
  68631. * Class used to create slider controls
  68632. */
  68633. export class BaseSlider extends Control {
  68634. name?: string | undefined;
  68635. protected _thumbWidth: ValueAndUnit;
  68636. private _minimum;
  68637. private _maximum;
  68638. private _value;
  68639. private _isVertical;
  68640. protected _barOffset: ValueAndUnit;
  68641. private _isThumbClamped;
  68642. protected _displayThumb: boolean;
  68643. private _step;
  68644. private _lastPointerDownID;
  68645. protected _effectiveBarOffset: number;
  68646. protected _renderLeft: number;
  68647. protected _renderTop: number;
  68648. protected _renderWidth: number;
  68649. protected _renderHeight: number;
  68650. protected _backgroundBoxLength: number;
  68651. protected _backgroundBoxThickness: number;
  68652. protected _effectiveThumbThickness: number;
  68653. /** BABYLON.Observable raised when the sldier value changes */
  68654. onValueChangedObservable: BABYLON.Observable<number>;
  68655. /** Gets or sets a boolean indicating if the thumb must be rendered */
  68656. displayThumb: boolean;
  68657. /** Gets or sets a step to apply to values (0 by default) */
  68658. step: number;
  68659. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  68660. barOffset: string | number;
  68661. /** Gets main bar offset in pixels*/
  68662. readonly barOffsetInPixels: number;
  68663. /** Gets or sets thumb width */
  68664. thumbWidth: string | number;
  68665. /** Gets thumb width in pixels */
  68666. readonly thumbWidthInPixels: number;
  68667. /** Gets or sets minimum value */
  68668. minimum: number;
  68669. /** Gets or sets maximum value */
  68670. maximum: number;
  68671. /** Gets or sets current value */
  68672. value: number;
  68673. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  68674. isVertical: boolean;
  68675. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  68676. isThumbClamped: boolean;
  68677. /**
  68678. * Creates a new BaseSlider
  68679. * @param name defines the control name
  68680. */
  68681. constructor(name?: string | undefined);
  68682. protected _getTypeName(): string;
  68683. protected _getThumbPosition(): number;
  68684. protected _getThumbThickness(type: string): number;
  68685. protected _prepareRenderingData(type: string): void;
  68686. private _pointerIsDown;
  68687. /** @hidden */
  68688. protected _updateValueFromPointer(x: number, y: number): void;
  68689. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68690. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  68691. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  68692. }
  68693. }
  68694. declare module BABYLON.GUI {
  68695. /**
  68696. * Class used to create slider controls
  68697. */
  68698. export class Slider extends BaseSlider {
  68699. name?: string | undefined;
  68700. private _background;
  68701. private _borderColor;
  68702. private _isThumbCircle;
  68703. protected _displayValueBar: boolean;
  68704. /** Gets or sets a boolean indicating if the value bar must be rendered */
  68705. displayValueBar: boolean;
  68706. /** Gets or sets border color */
  68707. borderColor: string;
  68708. /** Gets or sets background color */
  68709. background: string;
  68710. /** Gets or sets a boolean indicating if the thumb should be round or square */
  68711. isThumbCircle: boolean;
  68712. /**
  68713. * Creates a new Slider
  68714. * @param name defines the control name
  68715. */
  68716. constructor(name?: string | undefined);
  68717. protected _getTypeName(): string;
  68718. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68719. }
  68720. }
  68721. declare module BABYLON.GUI {
  68722. /** Class used to create a RadioGroup
  68723. * which contains groups of radio buttons
  68724. */
  68725. export class SelectorGroup {
  68726. /** name of SelectorGroup */
  68727. name: string;
  68728. private _groupPanel;
  68729. private _selectors;
  68730. private _groupHeader;
  68731. /**
  68732. * Creates a new SelectorGroup
  68733. * @param name of group, used as a group heading
  68734. */
  68735. constructor(
  68736. /** name of SelectorGroup */
  68737. name: string);
  68738. /** Gets the groupPanel of the SelectorGroup */
  68739. readonly groupPanel: StackPanel;
  68740. /** Gets the selectors array */
  68741. readonly selectors: StackPanel[];
  68742. /** Gets and sets the group header */
  68743. header: string;
  68744. /** @hidden */
  68745. private _addGroupHeader;
  68746. /** @hidden*/
  68747. _getSelector(selectorNb: number): StackPanel | undefined;
  68748. /** Removes the selector at the given position
  68749. * @param selectorNb the position of the selector within the group
  68750. */
  68751. removeSelector(selectorNb: number): void;
  68752. }
  68753. /** Class used to create a CheckboxGroup
  68754. * which contains groups of checkbox buttons
  68755. */
  68756. export class CheckboxGroup extends SelectorGroup {
  68757. /** Adds a checkbox as a control
  68758. * @param text is the label for the selector
  68759. * @param func is the function called when the Selector is checked
  68760. * @param checked is true when Selector is checked
  68761. */
  68762. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  68763. /** @hidden */
  68764. _setSelectorLabel(selectorNb: number, label: string): void;
  68765. /** @hidden */
  68766. _setSelectorLabelColor(selectorNb: number, color: string): void;
  68767. /** @hidden */
  68768. _setSelectorButtonColor(selectorNb: number, color: string): void;
  68769. /** @hidden */
  68770. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  68771. }
  68772. /** Class used to create a RadioGroup
  68773. * which contains groups of radio buttons
  68774. */
  68775. export class RadioGroup extends SelectorGroup {
  68776. private _selectNb;
  68777. /** Adds a radio button as a control
  68778. * @param label is the label for the selector
  68779. * @param func is the function called when the Selector is checked
  68780. * @param checked is true when Selector is checked
  68781. */
  68782. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  68783. /** @hidden */
  68784. _setSelectorLabel(selectorNb: number, label: string): void;
  68785. /** @hidden */
  68786. _setSelectorLabelColor(selectorNb: number, color: string): void;
  68787. /** @hidden */
  68788. _setSelectorButtonColor(selectorNb: number, color: string): void;
  68789. /** @hidden */
  68790. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  68791. }
  68792. /** Class used to create a SliderGroup
  68793. * which contains groups of slider buttons
  68794. */
  68795. export class SliderGroup extends SelectorGroup {
  68796. /**
  68797. * Adds a slider to the SelectorGroup
  68798. * @param label is the label for the SliderBar
  68799. * @param func is the function called when the Slider moves
  68800. * @param unit is a string describing the units used, eg degrees or metres
  68801. * @param min is the minimum value for the Slider
  68802. * @param max is the maximum value for the Slider
  68803. * @param value is the start value for the Slider between min and max
  68804. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  68805. */
  68806. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  68807. /** @hidden */
  68808. _setSelectorLabel(selectorNb: number, label: string): void;
  68809. /** @hidden */
  68810. _setSelectorLabelColor(selectorNb: number, color: string): void;
  68811. /** @hidden */
  68812. _setSelectorButtonColor(selectorNb: number, color: string): void;
  68813. /** @hidden */
  68814. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  68815. }
  68816. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  68817. * @see http://doc.babylonjs.com/how_to/selector
  68818. */
  68819. export class SelectionPanel extends Rectangle {
  68820. /** name of SelectionPanel */
  68821. name: string;
  68822. /** an array of SelectionGroups */
  68823. groups: SelectorGroup[];
  68824. private _panel;
  68825. private _buttonColor;
  68826. private _buttonBackground;
  68827. private _headerColor;
  68828. private _barColor;
  68829. private _barHeight;
  68830. private _spacerHeight;
  68831. private _labelColor;
  68832. private _groups;
  68833. private _bars;
  68834. /**
  68835. * Creates a new SelectionPanel
  68836. * @param name of SelectionPanel
  68837. * @param groups is an array of SelectionGroups
  68838. */
  68839. constructor(
  68840. /** name of SelectionPanel */
  68841. name: string,
  68842. /** an array of SelectionGroups */
  68843. groups?: SelectorGroup[]);
  68844. protected _getTypeName(): string;
  68845. /** Gets or sets the headerColor */
  68846. headerColor: string;
  68847. private _setHeaderColor;
  68848. /** Gets or sets the button color */
  68849. buttonColor: string;
  68850. private _setbuttonColor;
  68851. /** Gets or sets the label color */
  68852. labelColor: string;
  68853. private _setLabelColor;
  68854. /** Gets or sets the button background */
  68855. buttonBackground: string;
  68856. private _setButtonBackground;
  68857. /** Gets or sets the color of separator bar */
  68858. barColor: string;
  68859. private _setBarColor;
  68860. /** Gets or sets the height of separator bar */
  68861. barHeight: string;
  68862. private _setBarHeight;
  68863. /** Gets or sets the height of spacers*/
  68864. spacerHeight: string;
  68865. private _setSpacerHeight;
  68866. /** Adds a bar between groups */
  68867. private _addSpacer;
  68868. /** Add a group to the selection panel
  68869. * @param group is the selector group to add
  68870. */
  68871. addGroup(group: SelectorGroup): void;
  68872. /** Remove the group from the given position
  68873. * @param groupNb is the position of the group in the list
  68874. */
  68875. removeGroup(groupNb: number): void;
  68876. /** Change a group header label
  68877. * @param label is the new group header label
  68878. * @param groupNb is the number of the group to relabel
  68879. * */
  68880. setHeaderName(label: string, groupNb: number): void;
  68881. /** Change selector label to the one given
  68882. * @param label is the new selector label
  68883. * @param groupNb is the number of the groupcontaining the selector
  68884. * @param selectorNb is the number of the selector within a group to relabel
  68885. * */
  68886. relabel(label: string, groupNb: number, selectorNb: number): void;
  68887. /** For a given group position remove the selector at the given position
  68888. * @param groupNb is the number of the group to remove the selector from
  68889. * @param selectorNb is the number of the selector within the group
  68890. */
  68891. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  68892. /** For a given group position of correct type add a checkbox button
  68893. * @param groupNb is the number of the group to remove the selector from
  68894. * @param label is the label for the selector
  68895. * @param func is the function called when the Selector is checked
  68896. * @param checked is true when Selector is checked
  68897. */
  68898. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  68899. /** For a given group position of correct type add a radio button
  68900. * @param groupNb is the number of the group to remove the selector from
  68901. * @param label is the label for the selector
  68902. * @param func is the function called when the Selector is checked
  68903. * @param checked is true when Selector is checked
  68904. */
  68905. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  68906. /**
  68907. * For a given slider group add a slider
  68908. * @param groupNb is the number of the group to add the slider to
  68909. * @param label is the label for the Slider
  68910. * @param func is the function called when the Slider moves
  68911. * @param unit is a string describing the units used, eg degrees or metres
  68912. * @param min is the minimum value for the Slider
  68913. * @param max is the maximum value for the Slider
  68914. * @param value is the start value for the Slider between min and max
  68915. * @param onVal is the function used to format the value displayed, eg radians to degrees
  68916. */
  68917. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  68918. }
  68919. }
  68920. declare module BABYLON.GUI {
  68921. /**
  68922. * Class used to hold a the container for ScrollViewer
  68923. * @hidden
  68924. */
  68925. export class _ScrollViewerWindow extends Container {
  68926. parentClientWidth: number;
  68927. parentClientHeight: number;
  68928. /**
  68929. * Creates a new ScrollViewerWindow
  68930. * @param name of ScrollViewerWindow
  68931. */
  68932. constructor(name?: string);
  68933. protected _getTypeName(): string;
  68934. /** @hidden */
  68935. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68936. protected _postMeasure(): void;
  68937. }
  68938. }
  68939. declare module BABYLON.GUI {
  68940. /**
  68941. * Class used to create slider controls
  68942. */
  68943. export class ScrollBar extends BaseSlider {
  68944. name?: string | undefined;
  68945. private _background;
  68946. private _borderColor;
  68947. private _tempMeasure;
  68948. /** Gets or sets border color */
  68949. borderColor: string;
  68950. /** Gets or sets background color */
  68951. background: string;
  68952. /**
  68953. * Creates a new Slider
  68954. * @param name defines the control name
  68955. */
  68956. constructor(name?: string | undefined);
  68957. protected _getTypeName(): string;
  68958. protected _getThumbThickness(): number;
  68959. _draw(context: CanvasRenderingContext2D): void;
  68960. private _first;
  68961. private _originX;
  68962. private _originY;
  68963. /** @hidden */
  68964. protected _updateValueFromPointer(x: number, y: number): void;
  68965. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68966. }
  68967. }
  68968. declare module BABYLON.GUI {
  68969. /**
  68970. * Class used to create slider controls
  68971. */
  68972. export class ImageScrollBar extends BaseSlider {
  68973. name?: string | undefined;
  68974. private _backgroundBaseImage;
  68975. private _backgroundImage;
  68976. private _thumbImage;
  68977. private _thumbBaseImage;
  68978. private _thumbLength;
  68979. private _thumbHeight;
  68980. private _barImageHeight;
  68981. private _tempMeasure;
  68982. /**
  68983. * Gets or sets the image used to render the background for horizontal bar
  68984. */
  68985. backgroundImage: Image;
  68986. /**
  68987. * Gets or sets the image used to render the thumb
  68988. */
  68989. thumbImage: Image;
  68990. /**
  68991. * Gets or sets the length of the thumb
  68992. */
  68993. thumbLength: number;
  68994. /**
  68995. * Gets or sets the height of the thumb
  68996. */
  68997. thumbHeight: number;
  68998. /**
  68999. * Gets or sets the height of the bar image
  69000. */
  69001. barImageHeight: number;
  69002. /**
  69003. * Creates a new ImageScrollBar
  69004. * @param name defines the control name
  69005. */
  69006. constructor(name?: string | undefined);
  69007. protected _getTypeName(): string;
  69008. protected _getThumbThickness(): number;
  69009. _draw(context: CanvasRenderingContext2D): void;
  69010. private _first;
  69011. private _originX;
  69012. private _originY;
  69013. /** @hidden */
  69014. protected _updateValueFromPointer(x: number, y: number): void;
  69015. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69016. }
  69017. }
  69018. declare module BABYLON.GUI {
  69019. /**
  69020. * Class used to hold a viewer window and sliders in a grid
  69021. */
  69022. export class ScrollViewer extends Rectangle {
  69023. private _grid;
  69024. private _horizontalBarSpace;
  69025. private _verticalBarSpace;
  69026. private _dragSpace;
  69027. private _horizontalBar;
  69028. private _verticalBar;
  69029. private _barColor;
  69030. private _barBackground;
  69031. private _barImage;
  69032. private _barBackgroundImage;
  69033. private _barSize;
  69034. private _endLeft;
  69035. private _endTop;
  69036. private _window;
  69037. private _pointerIsOver;
  69038. private _wheelPrecision;
  69039. private _onPointerObserver;
  69040. private _clientWidth;
  69041. private _clientHeight;
  69042. private _useImageBar;
  69043. private _thumbLength;
  69044. private _thumbHeight;
  69045. private _barImageHeight;
  69046. /**
  69047. * Gets the horizontal scrollbar
  69048. */
  69049. readonly horizontalBar: ScrollBar | ImageScrollBar;
  69050. /**
  69051. * Gets the vertical scrollbar
  69052. */
  69053. readonly verticalBar: ScrollBar | ImageScrollBar;
  69054. /**
  69055. * Adds a new control to the current container
  69056. * @param control defines the control to add
  69057. * @returns the current container
  69058. */
  69059. addControl(control: BABYLON.Nullable<Control>): Container;
  69060. /**
  69061. * Removes a control from the current container
  69062. * @param control defines the control to remove
  69063. * @returns the current container
  69064. */
  69065. removeControl(control: Control): Container;
  69066. /** Gets the list of children */
  69067. readonly children: Control[];
  69068. _flagDescendantsAsMatrixDirty(): void;
  69069. /**
  69070. * Creates a new ScrollViewer
  69071. * @param name of ScrollViewer
  69072. */
  69073. constructor(name?: string, isImageBased?: boolean);
  69074. /** Reset the scroll viewer window to initial size */
  69075. resetWindow(): void;
  69076. protected _getTypeName(): string;
  69077. private _buildClientSizes;
  69078. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69079. protected _postMeasure(): void;
  69080. /**
  69081. * Gets or sets the mouse wheel precision
  69082. * from 0 to 1 with a default value of 0.05
  69083. * */
  69084. wheelPrecision: number;
  69085. /** Gets or sets the scroll bar container background color */
  69086. scrollBackground: string;
  69087. /** Gets or sets the bar color */
  69088. barColor: string;
  69089. /** Gets or sets the bar image */
  69090. thumbImage: Image;
  69091. /** Gets or sets the size of the bar */
  69092. barSize: number;
  69093. /** Gets or sets the length of the thumb */
  69094. thumbLength: number;
  69095. /** Gets or sets the height of the thumb */
  69096. thumbHeight: number;
  69097. /** Gets or sets the height of the bar image */
  69098. barImageHeight: number;
  69099. /** Gets or sets the bar background */
  69100. barBackground: string;
  69101. /** Gets or sets the bar background image */
  69102. barImage: Image;
  69103. /** @hidden */
  69104. private _updateScroller;
  69105. _link(host: AdvancedDynamicTexture): void;
  69106. /** @hidden */
  69107. private _addBar;
  69108. /** @hidden */
  69109. private _attachWheel;
  69110. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  69111. /** Releases associated resources */
  69112. dispose(): void;
  69113. }
  69114. }
  69115. declare module BABYLON.GUI {
  69116. /** Class used to render a grid */
  69117. export class DisplayGrid extends Control {
  69118. name?: string | undefined;
  69119. private _cellWidth;
  69120. private _cellHeight;
  69121. private _minorLineTickness;
  69122. private _minorLineColor;
  69123. private _majorLineTickness;
  69124. private _majorLineColor;
  69125. private _majorLineFrequency;
  69126. private _background;
  69127. private _displayMajorLines;
  69128. private _displayMinorLines;
  69129. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  69130. displayMinorLines: boolean;
  69131. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  69132. displayMajorLines: boolean;
  69133. /** Gets or sets background color (Black by default) */
  69134. background: string;
  69135. /** Gets or sets the width of each cell (20 by default) */
  69136. cellWidth: number;
  69137. /** Gets or sets the height of each cell (20 by default) */
  69138. cellHeight: number;
  69139. /** Gets or sets the tickness of minor lines (1 by default) */
  69140. minorLineTickness: number;
  69141. /** Gets or sets the color of minor lines (DarkGray by default) */
  69142. minorLineColor: string;
  69143. /** Gets or sets the tickness of major lines (2 by default) */
  69144. majorLineTickness: number;
  69145. /** Gets or sets the color of major lines (White by default) */
  69146. majorLineColor: string;
  69147. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  69148. majorLineFrequency: number;
  69149. /**
  69150. * Creates a new GridDisplayRectangle
  69151. * @param name defines the control name
  69152. */
  69153. constructor(name?: string | undefined);
  69154. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69155. protected _getTypeName(): string;
  69156. }
  69157. }
  69158. declare module BABYLON.GUI {
  69159. /**
  69160. * Class used to create slider controls based on images
  69161. */
  69162. export class ImageBasedSlider extends BaseSlider {
  69163. name?: string | undefined;
  69164. private _backgroundImage;
  69165. private _thumbImage;
  69166. private _valueBarImage;
  69167. private _tempMeasure;
  69168. displayThumb: boolean;
  69169. /**
  69170. * Gets or sets the image used to render the background
  69171. */
  69172. backgroundImage: Image;
  69173. /**
  69174. * Gets or sets the image used to render the value bar
  69175. */
  69176. valueBarImage: Image;
  69177. /**
  69178. * Gets or sets the image used to render the thumb
  69179. */
  69180. thumbImage: Image;
  69181. /**
  69182. * Creates a new ImageBasedSlider
  69183. * @param name defines the control name
  69184. */
  69185. constructor(name?: string | undefined);
  69186. protected _getTypeName(): string;
  69187. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69188. }
  69189. }
  69190. declare module BABYLON.GUI {
  69191. /**
  69192. * Forcing an export so that this code will execute
  69193. * @hidden
  69194. */
  69195. const name = "Statics";
  69196. }
  69197. declare module BABYLON.GUI {
  69198. /**
  69199. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  69200. */
  69201. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  69202. /**
  69203. * Define the instrumented AdvancedDynamicTexture.
  69204. */
  69205. texture: AdvancedDynamicTexture;
  69206. private _captureRenderTime;
  69207. private _renderTime;
  69208. private _captureLayoutTime;
  69209. private _layoutTime;
  69210. private _onBeginRenderObserver;
  69211. private _onEndRenderObserver;
  69212. private _onBeginLayoutObserver;
  69213. private _onEndLayoutObserver;
  69214. /**
  69215. * Gets the perf counter used to capture render time
  69216. */
  69217. readonly renderTimeCounter: BABYLON.PerfCounter;
  69218. /**
  69219. * Gets the perf counter used to capture layout time
  69220. */
  69221. readonly layoutTimeCounter: BABYLON.PerfCounter;
  69222. /**
  69223. * Enable or disable the render time capture
  69224. */
  69225. captureRenderTime: boolean;
  69226. /**
  69227. * Enable or disable the layout time capture
  69228. */
  69229. captureLayoutTime: boolean;
  69230. /**
  69231. * Instantiates a new advanced dynamic texture instrumentation.
  69232. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  69233. * @param texture Defines the AdvancedDynamicTexture to instrument
  69234. */
  69235. constructor(
  69236. /**
  69237. * Define the instrumented AdvancedDynamicTexture.
  69238. */
  69239. texture: AdvancedDynamicTexture);
  69240. /**
  69241. * Dispose and release associated resources.
  69242. */
  69243. dispose(): void;
  69244. }
  69245. }
  69246. declare module BABYLON.GUI {
  69247. /**
  69248. * Class used to load GUI via XML.
  69249. */
  69250. export class XmlLoader {
  69251. private _nodes;
  69252. private _nodeTypes;
  69253. private _isLoaded;
  69254. private _objectAttributes;
  69255. private _parentClass;
  69256. /**
  69257. * Create a new xml loader
  69258. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  69259. */
  69260. constructor(parentClass?: null);
  69261. private _getChainElement;
  69262. private _getClassAttribute;
  69263. private _createGuiElement;
  69264. private _parseGrid;
  69265. private _parseElement;
  69266. private _prepareSourceElement;
  69267. private _parseElementsFromSource;
  69268. private _parseXml;
  69269. /**
  69270. * Gets if the loading has finished.
  69271. * @returns whether the loading has finished or not
  69272. */
  69273. isLoaded(): boolean;
  69274. /**
  69275. * Gets a loaded node / control by id.
  69276. * @param id the Controls id set in the xml
  69277. * @returns element of type Control
  69278. */
  69279. getNodeById(id: string): any;
  69280. /**
  69281. * Gets all loaded nodes / controls
  69282. * @returns Array of controls
  69283. */
  69284. getNodes(): any;
  69285. /**
  69286. * Initiates the xml layout loading
  69287. * @param xmlFile defines the xml layout to load
  69288. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  69289. * @param callback defines the callback called on layout load.
  69290. */
  69291. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  69292. }
  69293. }
  69294. declare module BABYLON.GUI {
  69295. /**
  69296. * Class used to create containers for controls
  69297. */
  69298. export class Container3D extends Control3D {
  69299. private _blockLayout;
  69300. /**
  69301. * Gets the list of child controls
  69302. */
  69303. protected _children: Control3D[];
  69304. /**
  69305. * Gets the list of child controls
  69306. */
  69307. readonly children: Array<Control3D>;
  69308. /**
  69309. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  69310. * This is helpful to optimize layout operation when adding multiple children in a row
  69311. */
  69312. blockLayout: boolean;
  69313. /**
  69314. * Creates a new container
  69315. * @param name defines the container name
  69316. */
  69317. constructor(name?: string);
  69318. /**
  69319. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  69320. * @returns the current container
  69321. */
  69322. updateLayout(): Container3D;
  69323. /**
  69324. * Gets a boolean indicating if the given control is in the children of this control
  69325. * @param control defines the control to check
  69326. * @returns true if the control is in the child list
  69327. */
  69328. containsControl(control: Control3D): boolean;
  69329. /**
  69330. * Adds a control to the children of this control
  69331. * @param control defines the control to add
  69332. * @returns the current container
  69333. */
  69334. addControl(control: Control3D): Container3D;
  69335. /**
  69336. * This function will be called everytime a new control is added
  69337. */
  69338. protected _arrangeChildren(): void;
  69339. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  69340. /**
  69341. * Removes a control from the children of this control
  69342. * @param control defines the control to remove
  69343. * @returns the current container
  69344. */
  69345. removeControl(control: Control3D): Container3D;
  69346. protected _getTypeName(): string;
  69347. /**
  69348. * Releases all associated resources
  69349. */
  69350. dispose(): void;
  69351. /** Control rotation will remain unchanged */
  69352. static readonly UNSET_ORIENTATION: number;
  69353. /** Control will rotate to make it look at sphere central axis */
  69354. static readonly FACEORIGIN_ORIENTATION: number;
  69355. /** Control will rotate to make it look back at sphere central axis */
  69356. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  69357. /** Control will rotate to look at z axis (0, 0, 1) */
  69358. static readonly FACEFORWARD_ORIENTATION: number;
  69359. /** Control will rotate to look at negative z axis (0, 0, -1) */
  69360. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  69361. }
  69362. }
  69363. declare module BABYLON.GUI {
  69364. /**
  69365. * Class used to manage 3D user interface
  69366. * @see http://doc.babylonjs.com/how_to/gui3d
  69367. */
  69368. export class GUI3DManager implements BABYLON.IDisposable {
  69369. private _scene;
  69370. private _sceneDisposeObserver;
  69371. private _utilityLayer;
  69372. private _rootContainer;
  69373. private _pointerObserver;
  69374. private _pointerOutObserver;
  69375. /** @hidden */
  69376. _lastPickedControl: Control3D;
  69377. /** @hidden */
  69378. _lastControlOver: {
  69379. [pointerId: number]: Control3D;
  69380. };
  69381. /** @hidden */
  69382. _lastControlDown: {
  69383. [pointerId: number]: Control3D;
  69384. };
  69385. /**
  69386. * BABYLON.Observable raised when the point picked by the pointer events changed
  69387. */
  69388. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  69389. /** @hidden */
  69390. _sharedMaterials: {
  69391. [key: string]: BABYLON.Material;
  69392. };
  69393. /** Gets the hosting scene */
  69394. readonly scene: BABYLON.Scene;
  69395. /** Gets associated utility layer */
  69396. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  69397. /**
  69398. * Creates a new GUI3DManager
  69399. * @param scene
  69400. */
  69401. constructor(scene?: BABYLON.Scene);
  69402. private _handlePointerOut;
  69403. private _doPicking;
  69404. /**
  69405. * Gets the root container
  69406. */
  69407. readonly rootContainer: Container3D;
  69408. /**
  69409. * Gets a boolean indicating if the given control is in the root child list
  69410. * @param control defines the control to check
  69411. * @returns true if the control is in the root child list
  69412. */
  69413. containsControl(control: Control3D): boolean;
  69414. /**
  69415. * Adds a control to the root child list
  69416. * @param control defines the control to add
  69417. * @returns the current manager
  69418. */
  69419. addControl(control: Control3D): GUI3DManager;
  69420. /**
  69421. * Removes a control from the root child list
  69422. * @param control defines the control to remove
  69423. * @returns the current container
  69424. */
  69425. removeControl(control: Control3D): GUI3DManager;
  69426. /**
  69427. * Releases all associated resources
  69428. */
  69429. dispose(): void;
  69430. }
  69431. }
  69432. declare module BABYLON.GUI {
  69433. /**
  69434. * Class used to transport BABYLON.Vector3 information for pointer events
  69435. */
  69436. export class Vector3WithInfo extends BABYLON.Vector3 {
  69437. /** defines the current mouse button index */
  69438. buttonIndex: number;
  69439. /**
  69440. * Creates a new Vector3WithInfo
  69441. * @param source defines the vector3 data to transport
  69442. * @param buttonIndex defines the current mouse button index
  69443. */
  69444. constructor(source: BABYLON.Vector3,
  69445. /** defines the current mouse button index */
  69446. buttonIndex?: number);
  69447. }
  69448. }
  69449. declare module BABYLON.GUI {
  69450. /**
  69451. * Class used as base class for controls
  69452. */
  69453. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  69454. /** Defines the control name */
  69455. name?: string | undefined;
  69456. /** @hidden */
  69457. _host: GUI3DManager;
  69458. private _node;
  69459. private _downCount;
  69460. private _enterCount;
  69461. private _downPointerIds;
  69462. private _isVisible;
  69463. /** Gets or sets the control position in world space */
  69464. position: BABYLON.Vector3;
  69465. /** Gets or sets the control scaling in world space */
  69466. scaling: BABYLON.Vector3;
  69467. /** Callback used to start pointer enter animation */
  69468. pointerEnterAnimation: () => void;
  69469. /** Callback used to start pointer out animation */
  69470. pointerOutAnimation: () => void;
  69471. /** Callback used to start pointer down animation */
  69472. pointerDownAnimation: () => void;
  69473. /** Callback used to start pointer up animation */
  69474. pointerUpAnimation: () => void;
  69475. /**
  69476. * An event triggered when the pointer move over the control
  69477. */
  69478. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  69479. /**
  69480. * An event triggered when the pointer move out of the control
  69481. */
  69482. onPointerOutObservable: BABYLON.Observable<Control3D>;
  69483. /**
  69484. * An event triggered when the pointer taps the control
  69485. */
  69486. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  69487. /**
  69488. * An event triggered when pointer is up
  69489. */
  69490. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  69491. /**
  69492. * An event triggered when a control is clicked on (with a mouse)
  69493. */
  69494. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  69495. /**
  69496. * An event triggered when pointer enters the control
  69497. */
  69498. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  69499. /**
  69500. * Gets or sets the parent container
  69501. */
  69502. parent: BABYLON.Nullable<Container3D>;
  69503. private _behaviors;
  69504. /**
  69505. * Gets the list of attached behaviors
  69506. * @see http://doc.babylonjs.com/features/behaviour
  69507. */
  69508. readonly behaviors: BABYLON.Behavior<Control3D>[];
  69509. /**
  69510. * Attach a behavior to the control
  69511. * @see http://doc.babylonjs.com/features/behaviour
  69512. * @param behavior defines the behavior to attach
  69513. * @returns the current control
  69514. */
  69515. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  69516. /**
  69517. * Remove an attached behavior
  69518. * @see http://doc.babylonjs.com/features/behaviour
  69519. * @param behavior defines the behavior to attach
  69520. * @returns the current control
  69521. */
  69522. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  69523. /**
  69524. * Gets an attached behavior by name
  69525. * @param name defines the name of the behavior to look for
  69526. * @see http://doc.babylonjs.com/features/behaviour
  69527. * @returns null if behavior was not found else the requested behavior
  69528. */
  69529. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  69530. /** Gets or sets a boolean indicating if the control is visible */
  69531. isVisible: boolean;
  69532. /**
  69533. * Creates a new control
  69534. * @param name defines the control name
  69535. */
  69536. constructor(
  69537. /** Defines the control name */
  69538. name?: string | undefined);
  69539. /**
  69540. * Gets a string representing the class name
  69541. */
  69542. readonly typeName: string;
  69543. /**
  69544. * Get the current class name of the control.
  69545. * @returns current class name
  69546. */
  69547. getClassName(): string;
  69548. protected _getTypeName(): string;
  69549. /**
  69550. * Gets the transform node used by this control
  69551. */
  69552. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  69553. /**
  69554. * Gets the mesh used to render this control
  69555. */
  69556. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  69557. /**
  69558. * Link the control as child of the given node
  69559. * @param node defines the node to link to. Use null to unlink the control
  69560. * @returns the current control
  69561. */
  69562. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  69563. /** @hidden **/
  69564. _prepareNode(scene: BABYLON.Scene): void;
  69565. /**
  69566. * Node creation.
  69567. * Can be overriden by children
  69568. * @param scene defines the scene where the node must be attached
  69569. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  69570. */
  69571. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  69572. /**
  69573. * Affect a material to the given mesh
  69574. * @param mesh defines the mesh which will represent the control
  69575. */
  69576. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  69577. /** @hidden */
  69578. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  69579. /** @hidden */
  69580. _onPointerEnter(target: Control3D): boolean;
  69581. /** @hidden */
  69582. _onPointerOut(target: Control3D): void;
  69583. /** @hidden */
  69584. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  69585. /** @hidden */
  69586. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  69587. /** @hidden */
  69588. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  69589. /** @hidden */
  69590. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  69591. /** @hidden */
  69592. _disposeNode(): void;
  69593. /**
  69594. * Releases all associated resources
  69595. */
  69596. dispose(): void;
  69597. }
  69598. }
  69599. declare module BABYLON.GUI {
  69600. /**
  69601. * Class used as a root to all buttons
  69602. */
  69603. export class AbstractButton3D extends Control3D {
  69604. /**
  69605. * Creates a new button
  69606. * @param name defines the control name
  69607. */
  69608. constructor(name?: string);
  69609. protected _getTypeName(): string;
  69610. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  69611. }
  69612. }
  69613. declare module BABYLON.GUI {
  69614. /**
  69615. * Class used to create a button in 3D
  69616. */
  69617. export class Button3D extends AbstractButton3D {
  69618. /** @hidden */
  69619. protected _currentMaterial: BABYLON.Material;
  69620. private _facadeTexture;
  69621. private _content;
  69622. private _contentResolution;
  69623. private _contentScaleRatio;
  69624. /**
  69625. * Gets or sets the texture resolution used to render content (512 by default)
  69626. */
  69627. contentResolution: BABYLON.int;
  69628. /**
  69629. * Gets or sets the texture scale ratio used to render content (2 by default)
  69630. */
  69631. contentScaleRatio: number;
  69632. protected _disposeFacadeTexture(): void;
  69633. protected _resetContent(): void;
  69634. /**
  69635. * Creates a new button
  69636. * @param name defines the control name
  69637. */
  69638. constructor(name?: string);
  69639. /**
  69640. * Gets or sets the GUI 2D content used to display the button's facade
  69641. */
  69642. content: Control;
  69643. /**
  69644. * Apply the facade texture (created from the content property).
  69645. * This function can be overloaded by child classes
  69646. * @param facadeTexture defines the AdvancedDynamicTexture to use
  69647. */
  69648. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  69649. protected _getTypeName(): string;
  69650. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  69651. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  69652. /**
  69653. * Releases all associated resources
  69654. */
  69655. dispose(): void;
  69656. }
  69657. }
  69658. declare module BABYLON.GUI {
  69659. /**
  69660. * Abstract class used to create a container panel deployed on the surface of a volume
  69661. */
  69662. export abstract class VolumeBasedPanel extends Container3D {
  69663. private _columns;
  69664. private _rows;
  69665. private _rowThenColum;
  69666. private _orientation;
  69667. protected _cellWidth: number;
  69668. protected _cellHeight: number;
  69669. /**
  69670. * Gets or sets the distance between elements
  69671. */
  69672. margin: number;
  69673. /**
  69674. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  69675. * | Value | Type | Description |
  69676. * | ----- | ----------------------------------- | ----------- |
  69677. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  69678. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  69679. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  69680. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  69681. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  69682. */
  69683. orientation: number;
  69684. /**
  69685. * Gets or sets the number of columns requested (10 by default).
  69686. * The panel will automatically compute the number of rows based on number of child controls.
  69687. */
  69688. columns: BABYLON.int;
  69689. /**
  69690. * Gets or sets a the number of rows requested.
  69691. * The panel will automatically compute the number of columns based on number of child controls.
  69692. */
  69693. rows: BABYLON.int;
  69694. /**
  69695. * Creates new VolumeBasedPanel
  69696. */
  69697. constructor();
  69698. protected _arrangeChildren(): void;
  69699. /** Child classes must implement this function to provide correct control positioning */
  69700. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  69701. /** Child classes can implement this function to provide additional processing */
  69702. protected _finalProcessing(): void;
  69703. }
  69704. }
  69705. declare module BABYLON.GUI {
  69706. /**
  69707. * Class used to create a container panel deployed on the surface of a cylinder
  69708. */
  69709. export class CylinderPanel extends VolumeBasedPanel {
  69710. private _radius;
  69711. /**
  69712. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  69713. */
  69714. radius: BABYLON.float;
  69715. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  69716. private _cylindricalMapping;
  69717. }
  69718. }
  69719. declare module BABYLON.GUI {
  69720. /** @hidden */
  69721. export var fluentVertexShader: {
  69722. name: string;
  69723. shader: string;
  69724. };
  69725. }
  69726. declare module BABYLON.GUI {
  69727. /** @hidden */
  69728. export var fluentPixelShader: {
  69729. name: string;
  69730. shader: string;
  69731. };
  69732. }
  69733. declare module BABYLON.GUI {
  69734. /** @hidden */
  69735. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  69736. INNERGLOW: boolean;
  69737. BORDER: boolean;
  69738. HOVERLIGHT: boolean;
  69739. TEXTURE: boolean;
  69740. constructor();
  69741. }
  69742. /**
  69743. * Class used to render controls with fluent desgin
  69744. */
  69745. export class FluentMaterial extends BABYLON.PushMaterial {
  69746. /**
  69747. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  69748. */
  69749. innerGlowColorIntensity: number;
  69750. /**
  69751. * Gets or sets the inner glow color (white by default)
  69752. */
  69753. innerGlowColor: BABYLON.Color3;
  69754. /**
  69755. * Gets or sets alpha value (default is 1.0)
  69756. */
  69757. alpha: number;
  69758. /**
  69759. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  69760. */
  69761. albedoColor: BABYLON.Color3;
  69762. /**
  69763. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  69764. */
  69765. renderBorders: boolean;
  69766. /**
  69767. * Gets or sets border width (default is 0.5)
  69768. */
  69769. borderWidth: number;
  69770. /**
  69771. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  69772. */
  69773. edgeSmoothingValue: number;
  69774. /**
  69775. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  69776. */
  69777. borderMinValue: number;
  69778. /**
  69779. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  69780. */
  69781. renderHoverLight: boolean;
  69782. /**
  69783. * Gets or sets the radius used to render the hover light (default is 1.0)
  69784. */
  69785. hoverRadius: number;
  69786. /**
  69787. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  69788. */
  69789. hoverColor: BABYLON.Color4;
  69790. /**
  69791. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  69792. */
  69793. hoverPosition: BABYLON.Vector3;
  69794. private _albedoTexture;
  69795. /** Gets or sets the texture to use for albedo color */
  69796. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69797. /**
  69798. * Creates a new Fluent material
  69799. * @param name defines the name of the material
  69800. * @param scene defines the hosting scene
  69801. */
  69802. constructor(name: string, scene: BABYLON.Scene);
  69803. needAlphaBlending(): boolean;
  69804. needAlphaTesting(): boolean;
  69805. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69806. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69807. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69808. getActiveTextures(): BABYLON.BaseTexture[];
  69809. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69810. dispose(forceDisposeEffect?: boolean): void;
  69811. clone(name: string): FluentMaterial;
  69812. serialize(): any;
  69813. getClassName(): string;
  69814. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  69815. }
  69816. }
  69817. declare module BABYLON.GUI {
  69818. /**
  69819. * Class used to create a holographic button in 3D
  69820. */
  69821. export class HolographicButton extends Button3D {
  69822. private _backPlate;
  69823. private _textPlate;
  69824. private _frontPlate;
  69825. private _text;
  69826. private _imageUrl;
  69827. private _shareMaterials;
  69828. private _frontMaterial;
  69829. private _backMaterial;
  69830. private _plateMaterial;
  69831. private _pickedPointObserver;
  69832. private _tooltipFade;
  69833. private _tooltipTextBlock;
  69834. private _tooltipTexture;
  69835. private _tooltipMesh;
  69836. private _tooltipHoverObserver;
  69837. private _tooltipOutObserver;
  69838. private _disposeTooltip;
  69839. /**
  69840. * Rendering ground id of all the mesh in the button
  69841. */
  69842. renderingGroupId: number;
  69843. /**
  69844. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  69845. */
  69846. tooltipText: BABYLON.Nullable<string>;
  69847. /**
  69848. * Gets or sets text for the button
  69849. */
  69850. text: string;
  69851. /**
  69852. * Gets or sets the image url for the button
  69853. */
  69854. imageUrl: string;
  69855. /**
  69856. * Gets the back material used by this button
  69857. */
  69858. readonly backMaterial: FluentMaterial;
  69859. /**
  69860. * Gets the front material used by this button
  69861. */
  69862. readonly frontMaterial: FluentMaterial;
  69863. /**
  69864. * Gets the plate material used by this button
  69865. */
  69866. readonly plateMaterial: BABYLON.StandardMaterial;
  69867. /**
  69868. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  69869. */
  69870. readonly shareMaterials: boolean;
  69871. /**
  69872. * Creates a new button
  69873. * @param name defines the control name
  69874. */
  69875. constructor(name?: string, shareMaterials?: boolean);
  69876. protected _getTypeName(): string;
  69877. private _rebuildContent;
  69878. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  69879. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  69880. private _createBackMaterial;
  69881. private _createFrontMaterial;
  69882. private _createPlateMaterial;
  69883. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  69884. /**
  69885. * Releases all associated resources
  69886. */
  69887. dispose(): void;
  69888. }
  69889. }
  69890. declare module BABYLON.GUI {
  69891. /**
  69892. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  69893. */
  69894. export class MeshButton3D extends Button3D {
  69895. /** @hidden */
  69896. protected _currentMesh: BABYLON.Mesh;
  69897. /**
  69898. * Creates a new 3D button based on a mesh
  69899. * @param mesh mesh to become a 3D button
  69900. * @param name defines the control name
  69901. */
  69902. constructor(mesh: BABYLON.Mesh, name?: string);
  69903. protected _getTypeName(): string;
  69904. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  69905. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  69906. }
  69907. }
  69908. declare module BABYLON.GUI {
  69909. /**
  69910. * Class used to create a container panel deployed on the surface of a plane
  69911. */
  69912. export class PlanePanel extends VolumeBasedPanel {
  69913. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  69914. }
  69915. }
  69916. declare module BABYLON.GUI {
  69917. /**
  69918. * Class used to create a container panel where items get randomized planar mapping
  69919. */
  69920. export class ScatterPanel extends VolumeBasedPanel {
  69921. private _iteration;
  69922. /**
  69923. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  69924. */
  69925. iteration: BABYLON.float;
  69926. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  69927. private _scatterMapping;
  69928. protected _finalProcessing(): void;
  69929. }
  69930. }
  69931. declare module BABYLON.GUI {
  69932. /**
  69933. * Class used to create a container panel deployed on the surface of a sphere
  69934. */
  69935. export class SpherePanel extends VolumeBasedPanel {
  69936. private _radius;
  69937. /**
  69938. * Gets or sets the radius of the sphere where to project controls (5 by default)
  69939. */
  69940. radius: BABYLON.float;
  69941. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  69942. private _sphericalMapping;
  69943. }
  69944. }
  69945. declare module BABYLON.GUI {
  69946. /**
  69947. * Class used to create a stack panel in 3D on XY plane
  69948. */
  69949. export class StackPanel3D extends Container3D {
  69950. private _isVertical;
  69951. /**
  69952. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  69953. */
  69954. isVertical: boolean;
  69955. /**
  69956. * Gets or sets the distance between elements
  69957. */
  69958. margin: number;
  69959. /**
  69960. * Creates new StackPanel
  69961. * @param isVertical
  69962. */
  69963. constructor(isVertical?: boolean);
  69964. protected _arrangeChildren(): void;
  69965. }
  69966. }
  69967. declare module BABYLON {
  69968. /**
  69969. * Mode that determines the coordinate system to use.
  69970. */
  69971. export enum GLTFLoaderCoordinateSystemMode {
  69972. /**
  69973. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  69974. */
  69975. AUTO = 0,
  69976. /**
  69977. * Sets the useRightHandedSystem flag on the scene.
  69978. */
  69979. FORCE_RIGHT_HANDED = 1
  69980. }
  69981. /**
  69982. * Mode that determines what animations will start.
  69983. */
  69984. export enum GLTFLoaderAnimationStartMode {
  69985. /**
  69986. * No animation will start.
  69987. */
  69988. NONE = 0,
  69989. /**
  69990. * The first animation will start.
  69991. */
  69992. FIRST = 1,
  69993. /**
  69994. * All animations will start.
  69995. */
  69996. ALL = 2
  69997. }
  69998. /**
  69999. * Interface that contains the data for the glTF asset.
  70000. */
  70001. export interface IGLTFLoaderData {
  70002. /**
  70003. * The object that represents the glTF JSON.
  70004. */
  70005. json: Object;
  70006. /**
  70007. * The BIN chunk of a binary glTF.
  70008. */
  70009. bin: Nullable<IDataBuffer>;
  70010. }
  70011. /**
  70012. * Interface for extending the loader.
  70013. */
  70014. export interface IGLTFLoaderExtension {
  70015. /**
  70016. * The name of this extension.
  70017. */
  70018. readonly name: string;
  70019. /**
  70020. * Defines whether this extension is enabled.
  70021. */
  70022. enabled: boolean;
  70023. /**
  70024. * Defines the order of this extension.
  70025. * The loader sorts the extensions using these values when loading.
  70026. */
  70027. order?: number;
  70028. }
  70029. /**
  70030. * Loader state.
  70031. */
  70032. export enum GLTFLoaderState {
  70033. /**
  70034. * The asset is loading.
  70035. */
  70036. LOADING = 0,
  70037. /**
  70038. * The asset is ready for rendering.
  70039. */
  70040. READY = 1,
  70041. /**
  70042. * The asset is completely loaded.
  70043. */
  70044. COMPLETE = 2
  70045. }
  70046. /** @hidden */
  70047. export interface IGLTFLoader extends IDisposable {
  70048. readonly state: Nullable<GLTFLoaderState>;
  70049. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  70050. meshes: AbstractMesh[];
  70051. particleSystems: IParticleSystem[];
  70052. skeletons: Skeleton[];
  70053. animationGroups: AnimationGroup[];
  70054. }>;
  70055. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  70056. }
  70057. /**
  70058. * File loader for loading glTF files into a scene.
  70059. */
  70060. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  70061. /** @hidden */
  70062. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  70063. /** @hidden */
  70064. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  70065. /**
  70066. * Raised when the asset has been parsed
  70067. */
  70068. onParsedObservable: Observable<IGLTFLoaderData>;
  70069. private _onParsedObserver;
  70070. /**
  70071. * Raised when the asset has been parsed
  70072. */
  70073. onParsed: (loaderData: IGLTFLoaderData) => void;
  70074. /**
  70075. * 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.
  70076. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  70077. * Defaults to true.
  70078. * @hidden
  70079. */
  70080. static IncrementalLoading: boolean;
  70081. /**
  70082. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  70083. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  70084. * @hidden
  70085. */
  70086. static HomogeneousCoordinates: boolean;
  70087. /**
  70088. * The coordinate system mode. Defaults to AUTO.
  70089. */
  70090. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  70091. /**
  70092. * The animation start mode. Defaults to FIRST.
  70093. */
  70094. animationStartMode: GLTFLoaderAnimationStartMode;
  70095. /**
  70096. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  70097. */
  70098. compileMaterials: boolean;
  70099. /**
  70100. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  70101. */
  70102. useClipPlane: boolean;
  70103. /**
  70104. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  70105. */
  70106. compileShadowGenerators: boolean;
  70107. /**
  70108. * Defines if the Alpha blended materials are only applied as coverage.
  70109. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  70110. * If true, no extra effects are applied to transparent pixels.
  70111. */
  70112. transparencyAsCoverage: boolean;
  70113. /**
  70114. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  70115. * Enabling will disable offline support and glTF validator.
  70116. * Defaults to false.
  70117. */
  70118. useRangeRequests: boolean;
  70119. /**
  70120. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  70121. */
  70122. createInstances: boolean;
  70123. /**
  70124. * Function called before loading a url referenced by the asset.
  70125. */
  70126. preprocessUrlAsync: (url: string) => Promise<string>;
  70127. /**
  70128. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  70129. */
  70130. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  70131. private _onMeshLoadedObserver;
  70132. /**
  70133. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  70134. */
  70135. onMeshLoaded: (mesh: AbstractMesh) => void;
  70136. /**
  70137. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  70138. */
  70139. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  70140. private _onTextureLoadedObserver;
  70141. /**
  70142. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  70143. */
  70144. onTextureLoaded: (texture: BaseTexture) => void;
  70145. /**
  70146. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  70147. */
  70148. readonly onMaterialLoadedObservable: Observable<Material>;
  70149. private _onMaterialLoadedObserver;
  70150. /**
  70151. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  70152. */
  70153. onMaterialLoaded: (material: Material) => void;
  70154. /**
  70155. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  70156. */
  70157. readonly onCameraLoadedObservable: Observable<Camera>;
  70158. private _onCameraLoadedObserver;
  70159. /**
  70160. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  70161. */
  70162. onCameraLoaded: (camera: Camera) => void;
  70163. /**
  70164. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  70165. * For assets with LODs, raised when all of the LODs are complete.
  70166. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  70167. */
  70168. readonly onCompleteObservable: Observable<void>;
  70169. private _onCompleteObserver;
  70170. /**
  70171. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  70172. * For assets with LODs, raised when all of the LODs are complete.
  70173. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  70174. */
  70175. onComplete: () => void;
  70176. /**
  70177. * Observable raised when an error occurs.
  70178. */
  70179. readonly onErrorObservable: Observable<any>;
  70180. private _onErrorObserver;
  70181. /**
  70182. * Callback raised when an error occurs.
  70183. */
  70184. onError: (reason: any) => void;
  70185. /**
  70186. * Observable raised after the loader is disposed.
  70187. */
  70188. readonly onDisposeObservable: Observable<void>;
  70189. private _onDisposeObserver;
  70190. /**
  70191. * Callback raised after the loader is disposed.
  70192. */
  70193. onDispose: () => void;
  70194. /**
  70195. * Observable raised after a loader extension is created.
  70196. * Set additional options for a loader extension in this event.
  70197. */
  70198. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  70199. private _onExtensionLoadedObserver;
  70200. /**
  70201. * Callback raised after a loader extension is created.
  70202. */
  70203. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  70204. /**
  70205. * Defines if the loader logging is enabled.
  70206. */
  70207. loggingEnabled: boolean;
  70208. /**
  70209. * Defines if the loader should capture performance counters.
  70210. */
  70211. capturePerformanceCounters: boolean;
  70212. /**
  70213. * Defines if the loader should validate the asset.
  70214. */
  70215. validate: boolean;
  70216. /**
  70217. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  70218. */
  70219. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  70220. private _onValidatedObserver;
  70221. /**
  70222. * Callback raised after a loader extension is created.
  70223. */
  70224. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  70225. private _loader;
  70226. /**
  70227. * Name of the loader ("gltf")
  70228. */
  70229. name: string;
  70230. /** @hidden */
  70231. extensions: ISceneLoaderPluginExtensions;
  70232. /**
  70233. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  70234. */
  70235. dispose(): void;
  70236. /** @hidden */
  70237. _clear(): void;
  70238. /** @hidden */
  70239. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  70240. /** @hidden */
  70241. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  70242. /** @hidden */
  70243. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  70244. meshes: AbstractMesh[];
  70245. particleSystems: IParticleSystem[];
  70246. skeletons: Skeleton[];
  70247. animationGroups: AnimationGroup[];
  70248. }>;
  70249. /** @hidden */
  70250. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  70251. /** @hidden */
  70252. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  70253. /** @hidden */
  70254. canDirectLoad(data: string): boolean;
  70255. /** @hidden */
  70256. directLoad(scene: Scene, data: string): any;
  70257. /**
  70258. * The callback that allows custom handling of the root url based on the response url.
  70259. * @param rootUrl the original root url
  70260. * @param responseURL the response url if available
  70261. * @returns the new root url
  70262. */
  70263. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  70264. /** @hidden */
  70265. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  70266. /**
  70267. * The loader state or null if the loader is not active.
  70268. */
  70269. readonly loaderState: Nullable<GLTFLoaderState>;
  70270. /**
  70271. * Returns a promise that resolves when the asset is completely loaded.
  70272. * @returns a promise that resolves when the asset is completely loaded.
  70273. */
  70274. whenCompleteAsync(): Promise<void>;
  70275. private _validateAsync;
  70276. private _getLoader;
  70277. private _parseJson;
  70278. private _unpackBinaryAsync;
  70279. private _unpackBinaryV1Async;
  70280. private _unpackBinaryV2Async;
  70281. private static _parseVersion;
  70282. private static _compareVersion;
  70283. private static readonly _logSpaces;
  70284. private _logIndentLevel;
  70285. private _loggingEnabled;
  70286. /** @hidden */
  70287. _log: (message: string) => void;
  70288. /** @hidden */
  70289. _logOpen(message: string): void;
  70290. /** @hidden */
  70291. _logClose(): void;
  70292. private _logEnabled;
  70293. private _logDisabled;
  70294. private _capturePerformanceCounters;
  70295. /** @hidden */
  70296. _startPerformanceCounter: (counterName: string) => void;
  70297. /** @hidden */
  70298. _endPerformanceCounter: (counterName: string) => void;
  70299. private _startPerformanceCounterEnabled;
  70300. private _startPerformanceCounterDisabled;
  70301. private _endPerformanceCounterEnabled;
  70302. private _endPerformanceCounterDisabled;
  70303. }
  70304. }
  70305. declare module BABYLON.GLTF1 {
  70306. /**
  70307. * Enums
  70308. * @hidden
  70309. */
  70310. export enum EComponentType {
  70311. BYTE = 5120,
  70312. UNSIGNED_BYTE = 5121,
  70313. SHORT = 5122,
  70314. UNSIGNED_SHORT = 5123,
  70315. FLOAT = 5126
  70316. }
  70317. /** @hidden */
  70318. export enum EShaderType {
  70319. FRAGMENT = 35632,
  70320. VERTEX = 35633
  70321. }
  70322. /** @hidden */
  70323. export enum EParameterType {
  70324. BYTE = 5120,
  70325. UNSIGNED_BYTE = 5121,
  70326. SHORT = 5122,
  70327. UNSIGNED_SHORT = 5123,
  70328. INT = 5124,
  70329. UNSIGNED_INT = 5125,
  70330. FLOAT = 5126,
  70331. FLOAT_VEC2 = 35664,
  70332. FLOAT_VEC3 = 35665,
  70333. FLOAT_VEC4 = 35666,
  70334. INT_VEC2 = 35667,
  70335. INT_VEC3 = 35668,
  70336. INT_VEC4 = 35669,
  70337. BOOL = 35670,
  70338. BOOL_VEC2 = 35671,
  70339. BOOL_VEC3 = 35672,
  70340. BOOL_VEC4 = 35673,
  70341. FLOAT_MAT2 = 35674,
  70342. FLOAT_MAT3 = 35675,
  70343. FLOAT_MAT4 = 35676,
  70344. SAMPLER_2D = 35678
  70345. }
  70346. /** @hidden */
  70347. export enum ETextureWrapMode {
  70348. CLAMP_TO_EDGE = 33071,
  70349. MIRRORED_REPEAT = 33648,
  70350. REPEAT = 10497
  70351. }
  70352. /** @hidden */
  70353. export enum ETextureFilterType {
  70354. NEAREST = 9728,
  70355. LINEAR = 9728,
  70356. NEAREST_MIPMAP_NEAREST = 9984,
  70357. LINEAR_MIPMAP_NEAREST = 9985,
  70358. NEAREST_MIPMAP_LINEAR = 9986,
  70359. LINEAR_MIPMAP_LINEAR = 9987
  70360. }
  70361. /** @hidden */
  70362. export enum ETextureFormat {
  70363. ALPHA = 6406,
  70364. RGB = 6407,
  70365. RGBA = 6408,
  70366. LUMINANCE = 6409,
  70367. LUMINANCE_ALPHA = 6410
  70368. }
  70369. /** @hidden */
  70370. export enum ECullingType {
  70371. FRONT = 1028,
  70372. BACK = 1029,
  70373. FRONT_AND_BACK = 1032
  70374. }
  70375. /** @hidden */
  70376. export enum EBlendingFunction {
  70377. ZERO = 0,
  70378. ONE = 1,
  70379. SRC_COLOR = 768,
  70380. ONE_MINUS_SRC_COLOR = 769,
  70381. DST_COLOR = 774,
  70382. ONE_MINUS_DST_COLOR = 775,
  70383. SRC_ALPHA = 770,
  70384. ONE_MINUS_SRC_ALPHA = 771,
  70385. DST_ALPHA = 772,
  70386. ONE_MINUS_DST_ALPHA = 773,
  70387. CONSTANT_COLOR = 32769,
  70388. ONE_MINUS_CONSTANT_COLOR = 32770,
  70389. CONSTANT_ALPHA = 32771,
  70390. ONE_MINUS_CONSTANT_ALPHA = 32772,
  70391. SRC_ALPHA_SATURATE = 776
  70392. }
  70393. /** @hidden */
  70394. export interface IGLTFProperty {
  70395. extensions?: {
  70396. [key: string]: any;
  70397. };
  70398. extras?: Object;
  70399. }
  70400. /** @hidden */
  70401. export interface IGLTFChildRootProperty extends IGLTFProperty {
  70402. name?: string;
  70403. }
  70404. /** @hidden */
  70405. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  70406. bufferView: string;
  70407. byteOffset: number;
  70408. byteStride: number;
  70409. count: number;
  70410. type: string;
  70411. componentType: EComponentType;
  70412. max?: number[];
  70413. min?: number[];
  70414. name?: string;
  70415. }
  70416. /** @hidden */
  70417. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  70418. buffer: string;
  70419. byteOffset: number;
  70420. byteLength: number;
  70421. byteStride: number;
  70422. target?: number;
  70423. }
  70424. /** @hidden */
  70425. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  70426. uri: string;
  70427. byteLength?: number;
  70428. type?: string;
  70429. }
  70430. /** @hidden */
  70431. export interface IGLTFShader extends IGLTFChildRootProperty {
  70432. uri: string;
  70433. type: EShaderType;
  70434. }
  70435. /** @hidden */
  70436. export interface IGLTFProgram extends IGLTFChildRootProperty {
  70437. attributes: string[];
  70438. fragmentShader: string;
  70439. vertexShader: string;
  70440. }
  70441. /** @hidden */
  70442. export interface IGLTFTechniqueParameter {
  70443. type: number;
  70444. count?: number;
  70445. semantic?: string;
  70446. node?: string;
  70447. value?: number | boolean | string | Array<any>;
  70448. source?: string;
  70449. babylonValue?: any;
  70450. }
  70451. /** @hidden */
  70452. export interface IGLTFTechniqueCommonProfile {
  70453. lightingModel: string;
  70454. texcoordBindings: Object;
  70455. parameters?: Array<any>;
  70456. }
  70457. /** @hidden */
  70458. export interface IGLTFTechniqueStatesFunctions {
  70459. blendColor?: number[];
  70460. blendEquationSeparate?: number[];
  70461. blendFuncSeparate?: number[];
  70462. colorMask: boolean[];
  70463. cullFace: number[];
  70464. }
  70465. /** @hidden */
  70466. export interface IGLTFTechniqueStates {
  70467. enable: number[];
  70468. functions: IGLTFTechniqueStatesFunctions;
  70469. }
  70470. /** @hidden */
  70471. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  70472. parameters: {
  70473. [key: string]: IGLTFTechniqueParameter;
  70474. };
  70475. program: string;
  70476. attributes: {
  70477. [key: string]: string;
  70478. };
  70479. uniforms: {
  70480. [key: string]: string;
  70481. };
  70482. states: IGLTFTechniqueStates;
  70483. }
  70484. /** @hidden */
  70485. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  70486. technique?: string;
  70487. values: string[];
  70488. }
  70489. /** @hidden */
  70490. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  70491. attributes: {
  70492. [key: string]: string;
  70493. };
  70494. indices: string;
  70495. material: string;
  70496. mode?: number;
  70497. }
  70498. /** @hidden */
  70499. export interface IGLTFMesh extends IGLTFChildRootProperty {
  70500. primitives: IGLTFMeshPrimitive[];
  70501. }
  70502. /** @hidden */
  70503. export interface IGLTFImage extends IGLTFChildRootProperty {
  70504. uri: string;
  70505. }
  70506. /** @hidden */
  70507. export interface IGLTFSampler extends IGLTFChildRootProperty {
  70508. magFilter?: number;
  70509. minFilter?: number;
  70510. wrapS?: number;
  70511. wrapT?: number;
  70512. }
  70513. /** @hidden */
  70514. export interface IGLTFTexture extends IGLTFChildRootProperty {
  70515. sampler: string;
  70516. source: string;
  70517. format?: ETextureFormat;
  70518. internalFormat?: ETextureFormat;
  70519. target?: number;
  70520. type?: number;
  70521. babylonTexture?: Texture;
  70522. }
  70523. /** @hidden */
  70524. export interface IGLTFAmbienLight {
  70525. color?: number[];
  70526. }
  70527. /** @hidden */
  70528. export interface IGLTFDirectionalLight {
  70529. color?: number[];
  70530. }
  70531. /** @hidden */
  70532. export interface IGLTFPointLight {
  70533. color?: number[];
  70534. constantAttenuation?: number;
  70535. linearAttenuation?: number;
  70536. quadraticAttenuation?: number;
  70537. }
  70538. /** @hidden */
  70539. export interface IGLTFSpotLight {
  70540. color?: number[];
  70541. constantAttenuation?: number;
  70542. fallOfAngle?: number;
  70543. fallOffExponent?: number;
  70544. linearAttenuation?: number;
  70545. quadraticAttenuation?: number;
  70546. }
  70547. /** @hidden */
  70548. export interface IGLTFLight extends IGLTFChildRootProperty {
  70549. type: string;
  70550. }
  70551. /** @hidden */
  70552. export interface IGLTFCameraOrthographic {
  70553. xmag: number;
  70554. ymag: number;
  70555. zfar: number;
  70556. znear: number;
  70557. }
  70558. /** @hidden */
  70559. export interface IGLTFCameraPerspective {
  70560. aspectRatio: number;
  70561. yfov: number;
  70562. zfar: number;
  70563. znear: number;
  70564. }
  70565. /** @hidden */
  70566. export interface IGLTFCamera extends IGLTFChildRootProperty {
  70567. type: string;
  70568. }
  70569. /** @hidden */
  70570. export interface IGLTFAnimationChannelTarget {
  70571. id: string;
  70572. path: string;
  70573. }
  70574. /** @hidden */
  70575. export interface IGLTFAnimationChannel {
  70576. sampler: string;
  70577. target: IGLTFAnimationChannelTarget;
  70578. }
  70579. /** @hidden */
  70580. export interface IGLTFAnimationSampler {
  70581. input: string;
  70582. output: string;
  70583. interpolation?: string;
  70584. }
  70585. /** @hidden */
  70586. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  70587. channels?: IGLTFAnimationChannel[];
  70588. parameters?: {
  70589. [key: string]: string;
  70590. };
  70591. samplers?: {
  70592. [key: string]: IGLTFAnimationSampler;
  70593. };
  70594. }
  70595. /** @hidden */
  70596. export interface IGLTFNodeInstanceSkin {
  70597. skeletons: string[];
  70598. skin: string;
  70599. meshes: string[];
  70600. }
  70601. /** @hidden */
  70602. export interface IGLTFSkins extends IGLTFChildRootProperty {
  70603. bindShapeMatrix: number[];
  70604. inverseBindMatrices: string;
  70605. jointNames: string[];
  70606. babylonSkeleton?: Skeleton;
  70607. }
  70608. /** @hidden */
  70609. export interface IGLTFNode extends IGLTFChildRootProperty {
  70610. camera?: string;
  70611. children: string[];
  70612. skin?: string;
  70613. jointName?: string;
  70614. light?: string;
  70615. matrix: number[];
  70616. mesh?: string;
  70617. meshes?: string[];
  70618. rotation?: number[];
  70619. scale?: number[];
  70620. translation?: number[];
  70621. babylonNode?: Node;
  70622. }
  70623. /** @hidden */
  70624. export interface IGLTFScene extends IGLTFChildRootProperty {
  70625. nodes: string[];
  70626. }
  70627. /** @hidden */
  70628. export interface IGLTFRuntime {
  70629. extensions: {
  70630. [key: string]: any;
  70631. };
  70632. accessors: {
  70633. [key: string]: IGLTFAccessor;
  70634. };
  70635. buffers: {
  70636. [key: string]: IGLTFBuffer;
  70637. };
  70638. bufferViews: {
  70639. [key: string]: IGLTFBufferView;
  70640. };
  70641. meshes: {
  70642. [key: string]: IGLTFMesh;
  70643. };
  70644. lights: {
  70645. [key: string]: IGLTFLight;
  70646. };
  70647. cameras: {
  70648. [key: string]: IGLTFCamera;
  70649. };
  70650. nodes: {
  70651. [key: string]: IGLTFNode;
  70652. };
  70653. images: {
  70654. [key: string]: IGLTFImage;
  70655. };
  70656. textures: {
  70657. [key: string]: IGLTFTexture;
  70658. };
  70659. shaders: {
  70660. [key: string]: IGLTFShader;
  70661. };
  70662. programs: {
  70663. [key: string]: IGLTFProgram;
  70664. };
  70665. samplers: {
  70666. [key: string]: IGLTFSampler;
  70667. };
  70668. techniques: {
  70669. [key: string]: IGLTFTechnique;
  70670. };
  70671. materials: {
  70672. [key: string]: IGLTFMaterial;
  70673. };
  70674. animations: {
  70675. [key: string]: IGLTFAnimation;
  70676. };
  70677. skins: {
  70678. [key: string]: IGLTFSkins;
  70679. };
  70680. currentScene?: Object;
  70681. scenes: {
  70682. [key: string]: IGLTFScene;
  70683. };
  70684. extensionsUsed: string[];
  70685. extensionsRequired?: string[];
  70686. buffersCount: number;
  70687. shaderscount: number;
  70688. scene: Scene;
  70689. rootUrl: string;
  70690. loadedBufferCount: number;
  70691. loadedBufferViews: {
  70692. [name: string]: ArrayBufferView;
  70693. };
  70694. loadedShaderCount: number;
  70695. importOnlyMeshes: boolean;
  70696. importMeshesNames?: string[];
  70697. dummyNodes: Node[];
  70698. }
  70699. /** @hidden */
  70700. export interface INodeToRoot {
  70701. bone: Bone;
  70702. node: IGLTFNode;
  70703. id: string;
  70704. }
  70705. /** @hidden */
  70706. export interface IJointNode {
  70707. node: IGLTFNode;
  70708. id: string;
  70709. }
  70710. }
  70711. declare module BABYLON.GLTF1 {
  70712. /**
  70713. * Utils functions for GLTF
  70714. * @hidden
  70715. */
  70716. export class GLTFUtils {
  70717. /**
  70718. * Sets the given "parameter" matrix
  70719. * @param scene: the Scene object
  70720. * @param source: the source node where to pick the matrix
  70721. * @param parameter: the GLTF technique parameter
  70722. * @param uniformName: the name of the shader's uniform
  70723. * @param shaderMaterial: the shader material
  70724. */
  70725. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  70726. /**
  70727. * Sets the given "parameter" matrix
  70728. * @param shaderMaterial: the shader material
  70729. * @param uniform: the name of the shader's uniform
  70730. * @param value: the value of the uniform
  70731. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  70732. */
  70733. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  70734. /**
  70735. * Returns the wrap mode of the texture
  70736. * @param mode: the mode value
  70737. */
  70738. static GetWrapMode(mode: number): number;
  70739. /**
  70740. * Returns the byte stride giving an accessor
  70741. * @param accessor: the GLTF accessor objet
  70742. */
  70743. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  70744. /**
  70745. * Returns the texture filter mode giving a mode value
  70746. * @param mode: the filter mode value
  70747. */
  70748. static GetTextureFilterMode(mode: number): ETextureFilterType;
  70749. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  70750. /**
  70751. * Returns a buffer from its accessor
  70752. * @param gltfRuntime: the GLTF runtime
  70753. * @param accessor: the GLTF accessor
  70754. */
  70755. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  70756. /**
  70757. * Decodes a buffer view into a string
  70758. * @param view: the buffer view
  70759. */
  70760. static DecodeBufferToText(view: ArrayBufferView): string;
  70761. /**
  70762. * Returns the default material of gltf. Related to
  70763. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  70764. * @param scene: the Babylon.js scene
  70765. */
  70766. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  70767. private static _DefaultMaterial;
  70768. }
  70769. }
  70770. declare module BABYLON.GLTF1 {
  70771. /**
  70772. * Implementation of the base glTF spec
  70773. * @hidden
  70774. */
  70775. export class GLTFLoaderBase {
  70776. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  70777. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  70778. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  70779. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  70780. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  70781. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  70782. }
  70783. /**
  70784. * glTF V1 Loader
  70785. * @hidden
  70786. */
  70787. export class GLTFLoader implements IGLTFLoader {
  70788. static Extensions: {
  70789. [name: string]: GLTFLoaderExtension;
  70790. };
  70791. static RegisterExtension(extension: GLTFLoaderExtension): void;
  70792. state: Nullable<GLTFLoaderState>;
  70793. dispose(): void;
  70794. private _importMeshAsync;
  70795. /**
  70796. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  70797. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  70798. * @param scene the scene the meshes should be added to
  70799. * @param data gltf data containing information of the meshes in a loaded file
  70800. * @param rootUrl root url to load from
  70801. * @param onProgress event that fires when loading progress has occured
  70802. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  70803. */
  70804. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  70805. meshes: AbstractMesh[];
  70806. particleSystems: IParticleSystem[];
  70807. skeletons: Skeleton[];
  70808. animationGroups: AnimationGroup[];
  70809. }>;
  70810. private _loadAsync;
  70811. /**
  70812. * Imports all objects from a loaded gltf file and adds them to the scene
  70813. * @param scene the scene the objects should be added to
  70814. * @param data gltf data containing information of the meshes in a loaded file
  70815. * @param rootUrl root url to load from
  70816. * @param onProgress event that fires when loading progress has occured
  70817. * @returns a promise which completes when objects have been loaded to the scene
  70818. */
  70819. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  70820. private _loadShadersAsync;
  70821. private _loadBuffersAsync;
  70822. private _createNodes;
  70823. }
  70824. /** @hidden */
  70825. export abstract class GLTFLoaderExtension {
  70826. private _name;
  70827. constructor(name: string);
  70828. readonly name: string;
  70829. /**
  70830. * Defines an override for loading the runtime
  70831. * Return true to stop further extensions from loading the runtime
  70832. */
  70833. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  70834. /**
  70835. * Defines an onverride for creating gltf runtime
  70836. * Return true to stop further extensions from creating the runtime
  70837. */
  70838. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  70839. /**
  70840. * Defines an override for loading buffers
  70841. * Return true to stop further extensions from loading this buffer
  70842. */
  70843. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  70844. /**
  70845. * Defines an override for loading texture buffers
  70846. * Return true to stop further extensions from loading this texture data
  70847. */
  70848. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  70849. /**
  70850. * Defines an override for creating textures
  70851. * Return true to stop further extensions from loading this texture
  70852. */
  70853. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  70854. /**
  70855. * Defines an override for loading shader strings
  70856. * Return true to stop further extensions from loading this shader data
  70857. */
  70858. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  70859. /**
  70860. * Defines an override for loading materials
  70861. * Return true to stop further extensions from loading this material
  70862. */
  70863. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  70864. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  70865. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  70866. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  70867. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  70868. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  70869. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  70870. private static LoadTextureBufferAsync;
  70871. private static CreateTextureAsync;
  70872. private static ApplyExtensions;
  70873. }
  70874. }
  70875. declare module BABYLON.GLTF1 {
  70876. /** @hidden */
  70877. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  70878. private _bin;
  70879. constructor();
  70880. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  70881. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  70882. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  70883. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  70884. }
  70885. }
  70886. declare module BABYLON.GLTF1 {
  70887. /** @hidden */
  70888. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  70889. constructor();
  70890. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  70891. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  70892. private _loadTexture;
  70893. }
  70894. }
  70895. declare module BABYLON.GLTF2.Loader {
  70896. /**
  70897. * Loader interface with an index field.
  70898. */
  70899. export interface IArrayItem {
  70900. /**
  70901. * The index of this item in the array.
  70902. */
  70903. index: number;
  70904. }
  70905. /**
  70906. * Loader interface with additional members.
  70907. */
  70908. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  70909. /** @hidden */
  70910. _data?: Promise<ArrayBufferView>;
  70911. /** @hidden */
  70912. _babylonVertexBuffer?: Promise<VertexBuffer>;
  70913. }
  70914. /**
  70915. * Loader interface with additional members.
  70916. */
  70917. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  70918. }
  70919. /** @hidden */
  70920. export interface _IAnimationSamplerData {
  70921. input: Float32Array;
  70922. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  70923. output: Float32Array;
  70924. }
  70925. /**
  70926. * Loader interface with additional members.
  70927. */
  70928. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  70929. /** @hidden */
  70930. _data?: Promise<_IAnimationSamplerData>;
  70931. }
  70932. /**
  70933. * Loader interface with additional members.
  70934. */
  70935. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  70936. channels: IAnimationChannel[];
  70937. samplers: IAnimationSampler[];
  70938. /** @hidden */
  70939. _babylonAnimationGroup?: AnimationGroup;
  70940. }
  70941. /**
  70942. * Loader interface with additional members.
  70943. */
  70944. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  70945. /** @hidden */
  70946. _data?: Promise<ArrayBufferView>;
  70947. }
  70948. /**
  70949. * Loader interface with additional members.
  70950. */
  70951. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  70952. /** @hidden */
  70953. _data?: Promise<ArrayBufferView>;
  70954. /** @hidden */
  70955. _babylonBuffer?: Promise<Buffer>;
  70956. }
  70957. /**
  70958. * Loader interface with additional members.
  70959. */
  70960. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  70961. }
  70962. /**
  70963. * Loader interface with additional members.
  70964. */
  70965. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  70966. /** @hidden */
  70967. _data?: Promise<ArrayBufferView>;
  70968. }
  70969. /**
  70970. * Loader interface with additional members.
  70971. */
  70972. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  70973. }
  70974. /**
  70975. * Loader interface with additional members.
  70976. */
  70977. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  70978. }
  70979. /**
  70980. * Loader interface with additional members.
  70981. */
  70982. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  70983. baseColorTexture?: ITextureInfo;
  70984. metallicRoughnessTexture?: ITextureInfo;
  70985. }
  70986. /**
  70987. * Loader interface with additional members.
  70988. */
  70989. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  70990. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  70991. normalTexture?: IMaterialNormalTextureInfo;
  70992. occlusionTexture?: IMaterialOcclusionTextureInfo;
  70993. emissiveTexture?: ITextureInfo;
  70994. /** @hidden */
  70995. _data?: {
  70996. [babylonDrawMode: number]: {
  70997. babylonMaterial: Material;
  70998. babylonMeshes: AbstractMesh[];
  70999. promise: Promise<void>;
  71000. };
  71001. };
  71002. }
  71003. /**
  71004. * Loader interface with additional members.
  71005. */
  71006. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  71007. primitives: IMeshPrimitive[];
  71008. }
  71009. /**
  71010. * Loader interface with additional members.
  71011. */
  71012. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  71013. /** @hidden */
  71014. _instanceData?: {
  71015. babylonSourceMesh: Mesh;
  71016. promise: Promise<any>;
  71017. };
  71018. }
  71019. /**
  71020. * Loader interface with additional members.
  71021. */
  71022. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  71023. /**
  71024. * The parent glTF node.
  71025. */
  71026. parent?: INode;
  71027. /** @hidden */
  71028. _babylonTransformNode?: TransformNode;
  71029. /** @hidden */
  71030. _primitiveBabylonMeshes?: AbstractMesh[];
  71031. /** @hidden */
  71032. _babylonBones?: Bone[];
  71033. /** @hidden */
  71034. _numMorphTargets?: number;
  71035. }
  71036. /** @hidden */
  71037. export interface _ISamplerData {
  71038. noMipMaps: boolean;
  71039. samplingMode: number;
  71040. wrapU: number;
  71041. wrapV: number;
  71042. }
  71043. /**
  71044. * Loader interface with additional members.
  71045. */
  71046. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  71047. /** @hidden */
  71048. _data?: _ISamplerData;
  71049. }
  71050. /**
  71051. * Loader interface with additional members.
  71052. */
  71053. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  71054. }
  71055. /**
  71056. * Loader interface with additional members.
  71057. */
  71058. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  71059. /** @hidden */
  71060. _data?: {
  71061. babylonSkeleton: Skeleton;
  71062. promise: Promise<void>;
  71063. };
  71064. }
  71065. /**
  71066. * Loader interface with additional members.
  71067. */
  71068. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  71069. }
  71070. /**
  71071. * Loader interface with additional members.
  71072. */
  71073. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  71074. }
  71075. /**
  71076. * Loader interface with additional members.
  71077. */
  71078. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  71079. accessors?: IAccessor[];
  71080. animations?: IAnimation[];
  71081. buffers?: IBuffer[];
  71082. bufferViews?: IBufferView[];
  71083. cameras?: ICamera[];
  71084. images?: IImage[];
  71085. materials?: IMaterial[];
  71086. meshes?: IMesh[];
  71087. nodes?: INode[];
  71088. samplers?: ISampler[];
  71089. scenes?: IScene[];
  71090. skins?: ISkin[];
  71091. textures?: ITexture[];
  71092. }
  71093. }
  71094. declare module BABYLON.GLTF2 {
  71095. /**
  71096. * Interface for a glTF loader extension.
  71097. */
  71098. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  71099. /**
  71100. * Called after the loader state changes to LOADING.
  71101. */
  71102. onLoading?(): void;
  71103. /**
  71104. * Called after the loader state changes to READY.
  71105. */
  71106. onReady?(): void;
  71107. /**
  71108. * Define this method to modify the default behavior when loading scenes.
  71109. * @param context The context when loading the asset
  71110. * @param scene The glTF scene property
  71111. * @returns A promise that resolves when the load is complete or null if not handled
  71112. */
  71113. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  71114. /**
  71115. * Define this method to modify the default behavior when loading nodes.
  71116. * @param context The context when loading the asset
  71117. * @param node The glTF node property
  71118. * @param assign A function called synchronously after parsing the glTF properties
  71119. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  71120. */
  71121. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  71122. /**
  71123. * Define this method to modify the default behavior when loading cameras.
  71124. * @param context The context when loading the asset
  71125. * @param camera The glTF camera property
  71126. * @param assign A function called synchronously after parsing the glTF properties
  71127. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  71128. */
  71129. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  71130. /**
  71131. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  71132. * @param context The context when loading the asset
  71133. * @param primitive The glTF mesh primitive property
  71134. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  71135. */
  71136. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  71137. /**
  71138. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  71139. * @param context The context when loading the asset
  71140. * @param name The mesh name when loading the asset
  71141. * @param node The glTF node when loading the asset
  71142. * @param mesh The glTF mesh when loading the asset
  71143. * @param primitive The glTF mesh primitive property
  71144. * @param assign A function called synchronously after parsing the glTF properties
  71145. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  71146. */
  71147. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  71148. /**
  71149. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  71150. * @param context The context when loading the asset
  71151. * @param material The glTF material property
  71152. * @param assign A function called synchronously after parsing the glTF properties
  71153. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  71154. */
  71155. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  71156. /**
  71157. * Define this method to modify the default behavior when creating materials.
  71158. * @param context The context when loading the asset
  71159. * @param material The glTF material property
  71160. * @param babylonDrawMode The draw mode for the Babylon material
  71161. * @returns The Babylon material or null if not handled
  71162. */
  71163. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  71164. /**
  71165. * Define this method to modify the default behavior when loading material properties.
  71166. * @param context The context when loading the asset
  71167. * @param material The glTF material property
  71168. * @param babylonMaterial The Babylon material
  71169. * @returns A promise that resolves when the load is complete or null if not handled
  71170. */
  71171. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71172. /**
  71173. * Define this method to modify the default behavior when loading texture infos.
  71174. * @param context The context when loading the asset
  71175. * @param textureInfo The glTF texture info property
  71176. * @param assign A function called synchronously after parsing the glTF properties
  71177. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  71178. */
  71179. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  71180. /**
  71181. * Define this method to modify the default behavior when loading animations.
  71182. * @param context The context when loading the asset
  71183. * @param animation The glTF animation property
  71184. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  71185. */
  71186. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  71187. /**
  71188. * @hidden Define this method to modify the default behavior when loading skins.
  71189. * @param context The context when loading the asset
  71190. * @param node The glTF node property
  71191. * @param skin The glTF skin property
  71192. * @returns A promise that resolves when the load is complete or null if not handled
  71193. */
  71194. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  71195. /**
  71196. * @hidden Define this method to modify the default behavior when loading uris.
  71197. * @param context The context when loading the asset
  71198. * @param property The glTF property associated with the uri
  71199. * @param uri The uri to load
  71200. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  71201. */
  71202. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  71203. /**
  71204. * Define this method to modify the default behavior when loading buffer views.
  71205. * @param context The context when loading the asset
  71206. * @param bufferView The glTF buffer view property
  71207. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  71208. */
  71209. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  71210. /**
  71211. * Define this method to modify the default behavior when loading buffers.
  71212. * @param context The context when loading the asset
  71213. * @param buffer The glTF buffer property
  71214. * @param byteOffset The byte offset to load
  71215. * @param byteLength The byte length to load
  71216. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  71217. */
  71218. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  71219. }
  71220. }
  71221. declare module BABYLON.GLTF2 {
  71222. /**
  71223. * Helper class for working with arrays when loading the glTF asset
  71224. */
  71225. export class ArrayItem {
  71226. /**
  71227. * Gets an item from the given array.
  71228. * @param context The context when loading the asset
  71229. * @param array The array to get the item from
  71230. * @param index The index to the array
  71231. * @returns The array item
  71232. */
  71233. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  71234. /**
  71235. * Assign an `index` field to each item of the given array.
  71236. * @param array The array of items
  71237. */
  71238. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  71239. }
  71240. /**
  71241. * The glTF 2.0 loader
  71242. */
  71243. export class GLTFLoader implements IGLTFLoader {
  71244. /** @hidden */
  71245. _completePromises: Promise<any>[];
  71246. private _disposed;
  71247. private _parent;
  71248. private _state;
  71249. private _extensions;
  71250. private _rootUrl;
  71251. private _fileName;
  71252. private _uniqueRootUrl;
  71253. private _gltf;
  71254. private _bin;
  71255. private _babylonScene;
  71256. private _rootBabylonMesh;
  71257. private _defaultBabylonMaterialData;
  71258. private _progressCallback?;
  71259. private _requests;
  71260. private static readonly _DefaultSampler;
  71261. private static _RegisteredExtensions;
  71262. /**
  71263. * Registers a loader extension.
  71264. * @param name The name of the loader extension.
  71265. * @param factory The factory function that creates the loader extension.
  71266. */
  71267. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  71268. /**
  71269. * Unregisters a loader extension.
  71270. * @param name The name of the loader extension.
  71271. * @returns A boolean indicating whether the extension has been unregistered
  71272. */
  71273. static UnregisterExtension(name: string): boolean;
  71274. /**
  71275. * Gets the loader state.
  71276. */
  71277. readonly state: Nullable<GLTFLoaderState>;
  71278. /**
  71279. * The object that represents the glTF JSON.
  71280. */
  71281. readonly gltf: IGLTF;
  71282. /**
  71283. * The BIN chunk of a binary glTF.
  71284. */
  71285. readonly bin: Nullable<IDataBuffer>;
  71286. /**
  71287. * The parent file loader.
  71288. */
  71289. readonly parent: GLTFFileLoader;
  71290. /**
  71291. * The Babylon scene when loading the asset.
  71292. */
  71293. readonly babylonScene: Scene;
  71294. /**
  71295. * The root Babylon mesh when loading the asset.
  71296. */
  71297. readonly rootBabylonMesh: Mesh;
  71298. /** @hidden */
  71299. constructor(parent: GLTFFileLoader);
  71300. /** @hidden */
  71301. dispose(): void;
  71302. /** @hidden */
  71303. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  71304. meshes: AbstractMesh[];
  71305. particleSystems: IParticleSystem[];
  71306. skeletons: Skeleton[];
  71307. animationGroups: AnimationGroup[];
  71308. }>;
  71309. /** @hidden */
  71310. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  71311. private _loadAsync;
  71312. private _loadData;
  71313. private _setupData;
  71314. private _loadExtensions;
  71315. private _checkExtensions;
  71316. private _setState;
  71317. private _createRootNode;
  71318. /**
  71319. * Loads a glTF scene.
  71320. * @param context The context when loading the asset
  71321. * @param scene The glTF scene property
  71322. * @returns A promise that resolves when the load is complete
  71323. */
  71324. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  71325. private _forEachPrimitive;
  71326. private _getMeshes;
  71327. private _getSkeletons;
  71328. private _getAnimationGroups;
  71329. private _startAnimations;
  71330. /**
  71331. * Loads a glTF node.
  71332. * @param context The context when loading the asset
  71333. * @param node The glTF node property
  71334. * @param assign A function called synchronously after parsing the glTF properties
  71335. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  71336. */
  71337. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  71338. private _loadMeshAsync;
  71339. /**
  71340. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  71341. * @param context The context when loading the asset
  71342. * @param name The mesh name when loading the asset
  71343. * @param node The glTF node when loading the asset
  71344. * @param mesh The glTF mesh when loading the asset
  71345. * @param primitive The glTF mesh primitive property
  71346. * @param assign A function called synchronously after parsing the glTF properties
  71347. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  71348. */
  71349. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  71350. private _loadVertexDataAsync;
  71351. private _createMorphTargets;
  71352. private _loadMorphTargetsAsync;
  71353. private _loadMorphTargetVertexDataAsync;
  71354. private static _LoadTransform;
  71355. private _loadSkinAsync;
  71356. private _loadBones;
  71357. private _loadBone;
  71358. private _loadSkinInverseBindMatricesDataAsync;
  71359. private _updateBoneMatrices;
  71360. private _getNodeMatrix;
  71361. /**
  71362. * Loads a glTF camera.
  71363. * @param context The context when loading the asset
  71364. * @param camera The glTF camera property
  71365. * @param assign A function called synchronously after parsing the glTF properties
  71366. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  71367. */
  71368. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  71369. private _loadAnimationsAsync;
  71370. /**
  71371. * Loads a glTF animation.
  71372. * @param context The context when loading the asset
  71373. * @param animation The glTF animation property
  71374. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  71375. */
  71376. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  71377. /**
  71378. * @hidden Loads a glTF animation channel.
  71379. * @param context The context when loading the asset
  71380. * @param animationContext The context of the animation when loading the asset
  71381. * @param animation The glTF animation property
  71382. * @param channel The glTF animation channel property
  71383. * @param babylonAnimationGroup The babylon animation group property
  71384. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  71385. * @returns A void promise when the channel load is complete
  71386. */
  71387. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  71388. private _loadAnimationSamplerAsync;
  71389. private _loadBufferAsync;
  71390. /**
  71391. * Loads a glTF buffer view.
  71392. * @param context The context when loading the asset
  71393. * @param bufferView The glTF buffer view property
  71394. * @returns A promise that resolves with the loaded data when the load is complete
  71395. */
  71396. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  71397. private _loadAccessorAsync;
  71398. private _loadFloatAccessorAsync;
  71399. private _loadIndicesAccessorAsync;
  71400. private _loadVertexBufferViewAsync;
  71401. private _loadVertexAccessorAsync;
  71402. private _loadMaterialMetallicRoughnessPropertiesAsync;
  71403. /** @hidden */
  71404. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  71405. private _createDefaultMaterial;
  71406. /**
  71407. * Creates a Babylon material from a glTF material.
  71408. * @param context The context when loading the asset
  71409. * @param material The glTF material property
  71410. * @param babylonDrawMode The draw mode for the Babylon material
  71411. * @returns The Babylon material
  71412. */
  71413. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  71414. /**
  71415. * Loads properties from a glTF material into a Babylon material.
  71416. * @param context The context when loading the asset
  71417. * @param material The glTF material property
  71418. * @param babylonMaterial The Babylon material
  71419. * @returns A promise that resolves when the load is complete
  71420. */
  71421. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  71422. /**
  71423. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  71424. * @param context The context when loading the asset
  71425. * @param material The glTF material property
  71426. * @param babylonMaterial The Babylon material
  71427. * @returns A promise that resolves when the load is complete
  71428. */
  71429. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  71430. /**
  71431. * Loads the alpha properties from a glTF material into a Babylon material.
  71432. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  71433. * @param context The context when loading the asset
  71434. * @param material The glTF material property
  71435. * @param babylonMaterial The Babylon material
  71436. */
  71437. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  71438. /**
  71439. * Loads a glTF texture info.
  71440. * @param context The context when loading the asset
  71441. * @param textureInfo The glTF texture info property
  71442. * @param assign A function called synchronously after parsing the glTF properties
  71443. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  71444. */
  71445. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  71446. private _loadTextureAsync;
  71447. private _loadSampler;
  71448. /**
  71449. * Loads a glTF image.
  71450. * @param context The context when loading the asset
  71451. * @param image The glTF image property
  71452. * @returns A promise that resolves with the loaded data when the load is complete
  71453. */
  71454. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  71455. /**
  71456. * Loads a glTF uri.
  71457. * @param context The context when loading the asset
  71458. * @param property The glTF property associated with the uri
  71459. * @param uri The base64 or relative uri
  71460. * @returns A promise that resolves with the loaded data when the load is complete
  71461. */
  71462. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  71463. private _onProgress;
  71464. /**
  71465. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  71466. * @param babylonObject the Babylon object with metadata
  71467. * @param pointer the JSON pointer
  71468. */
  71469. static AddPointerMetadata(babylonObject: {
  71470. metadata: any;
  71471. }, pointer: string): void;
  71472. private static _GetTextureWrapMode;
  71473. private static _GetTextureSamplingMode;
  71474. private static _GetTypedArrayConstructor;
  71475. private static _GetTypedArray;
  71476. private static _GetNumComponents;
  71477. private static _ValidateUri;
  71478. private static _GetDrawMode;
  71479. private _compileMaterialsAsync;
  71480. private _compileShadowGeneratorsAsync;
  71481. private _forEachExtensions;
  71482. private _applyExtensions;
  71483. private _extensionsOnLoading;
  71484. private _extensionsOnReady;
  71485. private _extensionsLoadSceneAsync;
  71486. private _extensionsLoadNodeAsync;
  71487. private _extensionsLoadCameraAsync;
  71488. private _extensionsLoadVertexDataAsync;
  71489. private _extensionsLoadMeshPrimitiveAsync;
  71490. private _extensionsLoadMaterialAsync;
  71491. private _extensionsCreateMaterial;
  71492. private _extensionsLoadMaterialPropertiesAsync;
  71493. private _extensionsLoadTextureInfoAsync;
  71494. private _extensionsLoadAnimationAsync;
  71495. private _extensionsLoadSkinAsync;
  71496. private _extensionsLoadUriAsync;
  71497. private _extensionsLoadBufferViewAsync;
  71498. private _extensionsLoadBufferAsync;
  71499. /**
  71500. * Helper method called by a loader extension to load an glTF extension.
  71501. * @param context The context when loading the asset
  71502. * @param property The glTF property to load the extension from
  71503. * @param extensionName The name of the extension to load
  71504. * @param actionAsync The action to run
  71505. * @returns The promise returned by actionAsync or null if the extension does not exist
  71506. */
  71507. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  71508. /**
  71509. * Helper method called by a loader extension to load a glTF extra.
  71510. * @param context The context when loading the asset
  71511. * @param property The glTF property to load the extra from
  71512. * @param extensionName The name of the extension to load
  71513. * @param actionAsync The action to run
  71514. * @returns The promise returned by actionAsync or null if the extra does not exist
  71515. */
  71516. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  71517. /**
  71518. * Checks for presence of an extension.
  71519. * @param name The name of the extension to check
  71520. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  71521. */
  71522. isExtensionUsed(name: string): boolean;
  71523. /**
  71524. * Increments the indentation level and logs a message.
  71525. * @param message The message to log
  71526. */
  71527. logOpen(message: string): void;
  71528. /**
  71529. * Decrements the indentation level.
  71530. */
  71531. logClose(): void;
  71532. /**
  71533. * Logs a message
  71534. * @param message The message to log
  71535. */
  71536. log(message: string): void;
  71537. /**
  71538. * Starts a performance counter.
  71539. * @param counterName The name of the performance counter
  71540. */
  71541. startPerformanceCounter(counterName: string): void;
  71542. /**
  71543. * Ends a performance counter.
  71544. * @param counterName The name of the performance counter
  71545. */
  71546. endPerformanceCounter(counterName: string): void;
  71547. }
  71548. }
  71549. declare module BABYLON.GLTF2.Loader.Extensions {
  71550. /**
  71551. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  71552. */
  71553. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  71554. /**
  71555. * The name of this extension.
  71556. */
  71557. readonly name: string;
  71558. /**
  71559. * Defines whether this extension is enabled.
  71560. */
  71561. enabled: boolean;
  71562. private _loader;
  71563. private _lights?;
  71564. /** @hidden */
  71565. constructor(loader: GLTFLoader);
  71566. /** @hidden */
  71567. dispose(): void;
  71568. /** @hidden */
  71569. onLoading(): void;
  71570. /** @hidden */
  71571. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  71572. private _loadLightAsync;
  71573. }
  71574. }
  71575. declare module BABYLON.GLTF2.Loader.Extensions {
  71576. /**
  71577. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  71578. */
  71579. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  71580. /**
  71581. * The name of this extension.
  71582. */
  71583. readonly name: string;
  71584. /**
  71585. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  71586. */
  71587. dracoCompression?: DracoCompression;
  71588. /**
  71589. * Defines whether this extension is enabled.
  71590. */
  71591. enabled: boolean;
  71592. private _loader;
  71593. /** @hidden */
  71594. constructor(loader: GLTFLoader);
  71595. /** @hidden */
  71596. dispose(): void;
  71597. /** @hidden */
  71598. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  71599. }
  71600. }
  71601. declare module BABYLON.GLTF2.Loader.Extensions {
  71602. /**
  71603. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  71604. */
  71605. export class KHR_lights implements IGLTFLoaderExtension {
  71606. /**
  71607. * The name of this extension.
  71608. */
  71609. readonly name: string;
  71610. /**
  71611. * Defines whether this extension is enabled.
  71612. */
  71613. enabled: boolean;
  71614. private _loader;
  71615. private _lights?;
  71616. /** @hidden */
  71617. constructor(loader: GLTFLoader);
  71618. /** @hidden */
  71619. dispose(): void;
  71620. /** @hidden */
  71621. onLoading(): void;
  71622. /** @hidden */
  71623. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  71624. }
  71625. }
  71626. declare module BABYLON.GLTF2.Loader.Extensions {
  71627. /**
  71628. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  71629. */
  71630. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  71631. /**
  71632. * The name of this extension.
  71633. */
  71634. readonly name: string;
  71635. /**
  71636. * Defines whether this extension is enabled.
  71637. */
  71638. enabled: boolean;
  71639. /**
  71640. * Defines a number that determines the order the extensions are applied.
  71641. */
  71642. order: number;
  71643. private _loader;
  71644. /** @hidden */
  71645. constructor(loader: GLTFLoader);
  71646. /** @hidden */
  71647. dispose(): void;
  71648. /** @hidden */
  71649. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71650. private _loadSpecularGlossinessPropertiesAsync;
  71651. }
  71652. }
  71653. declare module BABYLON.GLTF2.Loader.Extensions {
  71654. /**
  71655. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  71656. */
  71657. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  71658. /**
  71659. * The name of this extension.
  71660. */
  71661. readonly name: string;
  71662. /**
  71663. * Defines whether this extension is enabled.
  71664. */
  71665. enabled: boolean;
  71666. /**
  71667. * Defines a number that determines the order the extensions are applied.
  71668. */
  71669. order: number;
  71670. private _loader;
  71671. /** @hidden */
  71672. constructor(loader: GLTFLoader);
  71673. /** @hidden */
  71674. dispose(): void;
  71675. /** @hidden */
  71676. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71677. private _loadUnlitPropertiesAsync;
  71678. }
  71679. }
  71680. declare module BABYLON.GLTF2.Loader.Extensions {
  71681. /**
  71682. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  71683. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  71684. * !!! Experimental Extension Subject to Changes !!!
  71685. */
  71686. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  71687. /**
  71688. * The name of this extension.
  71689. */
  71690. readonly name: string;
  71691. /**
  71692. * Defines whether this extension is enabled.
  71693. */
  71694. enabled: boolean;
  71695. /**
  71696. * Defines a number that determines the order the extensions are applied.
  71697. */
  71698. order: number;
  71699. private _loader;
  71700. /** @hidden */
  71701. constructor(loader: GLTFLoader);
  71702. /** @hidden */
  71703. dispose(): void;
  71704. /** @hidden */
  71705. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71706. private _loadClearCoatPropertiesAsync;
  71707. }
  71708. }
  71709. declare module BABYLON.GLTF2.Loader.Extensions {
  71710. /**
  71711. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  71712. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  71713. * !!! Experimental Extension Subject to Changes !!!
  71714. */
  71715. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  71716. /**
  71717. * The name of this extension.
  71718. */
  71719. readonly name: string;
  71720. /**
  71721. * Defines whether this extension is enabled.
  71722. */
  71723. enabled: boolean;
  71724. /**
  71725. * Defines a number that determines the order the extensions are applied.
  71726. */
  71727. order: number;
  71728. private _loader;
  71729. /** @hidden */
  71730. constructor(loader: GLTFLoader);
  71731. /** @hidden */
  71732. dispose(): void;
  71733. /** @hidden */
  71734. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71735. private _loadSheenPropertiesAsync;
  71736. }
  71737. }
  71738. declare module BABYLON.GLTF2.Loader.Extensions {
  71739. /**
  71740. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  71741. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  71742. * !!! Experimental Extension Subject to Changes !!!
  71743. */
  71744. export class KHR_materials_specular implements IGLTFLoaderExtension {
  71745. /**
  71746. * The name of this extension.
  71747. */
  71748. readonly name: string;
  71749. /**
  71750. * Defines whether this extension is enabled.
  71751. */
  71752. enabled: boolean;
  71753. /**
  71754. * Defines a number that determines the order the extensions are applied.
  71755. */
  71756. order: number;
  71757. private _loader;
  71758. /** @hidden */
  71759. constructor(loader: GLTFLoader);
  71760. /** @hidden */
  71761. dispose(): void;
  71762. /** @hidden */
  71763. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71764. private _loadSpecularPropertiesAsync;
  71765. }
  71766. }
  71767. declare module BABYLON.GLTF2.Loader.Extensions {
  71768. /**
  71769. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  71770. */
  71771. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  71772. /**
  71773. * The name of this extension.
  71774. */
  71775. readonly name: string;
  71776. /**
  71777. * Defines whether this extension is enabled.
  71778. */
  71779. enabled: boolean;
  71780. /** @hidden */
  71781. constructor(loader: GLTFLoader);
  71782. /** @hidden */
  71783. dispose(): void;
  71784. }
  71785. }
  71786. declare module BABYLON.GLTF2.Loader.Extensions {
  71787. /**
  71788. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  71789. */
  71790. export class KHR_texture_transform implements IGLTFLoaderExtension {
  71791. /**
  71792. * The name of this extension.
  71793. */
  71794. readonly name: string;
  71795. /**
  71796. * Defines whether this extension is enabled.
  71797. */
  71798. enabled: boolean;
  71799. private _loader;
  71800. /** @hidden */
  71801. constructor(loader: GLTFLoader);
  71802. /** @hidden */
  71803. dispose(): void;
  71804. /** @hidden */
  71805. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  71806. }
  71807. }
  71808. declare module BABYLON.GLTF2.Loader.Extensions {
  71809. /**
  71810. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  71811. */
  71812. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  71813. /**
  71814. * The name of this extension.
  71815. */
  71816. readonly name: string;
  71817. /**
  71818. * Defines whether this extension is enabled.
  71819. */
  71820. enabled: boolean;
  71821. private _loader;
  71822. private _clips;
  71823. private _emitters;
  71824. /** @hidden */
  71825. constructor(loader: GLTFLoader);
  71826. /** @hidden */
  71827. dispose(): void;
  71828. /** @hidden */
  71829. onLoading(): void;
  71830. /** @hidden */
  71831. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  71832. /** @hidden */
  71833. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  71834. /** @hidden */
  71835. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  71836. private _loadClipAsync;
  71837. private _loadEmitterAsync;
  71838. private _getEventAction;
  71839. private _loadAnimationEventAsync;
  71840. }
  71841. }
  71842. declare module BABYLON.GLTF2.Loader.Extensions {
  71843. /**
  71844. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  71845. */
  71846. export class MSFT_lod implements IGLTFLoaderExtension {
  71847. /**
  71848. * The name of this extension.
  71849. */
  71850. readonly name: string;
  71851. /**
  71852. * Defines whether this extension is enabled.
  71853. */
  71854. enabled: boolean;
  71855. /**
  71856. * Defines a number that determines the order the extensions are applied.
  71857. */
  71858. order: number;
  71859. /**
  71860. * Maximum number of LODs to load, starting from the lowest LOD.
  71861. */
  71862. maxLODsToLoad: number;
  71863. /**
  71864. * Observable raised when all node LODs of one level are loaded.
  71865. * The event data is the index of the loaded LOD starting from zero.
  71866. * Dispose the loader to cancel the loading of the next level of LODs.
  71867. */
  71868. onNodeLODsLoadedObservable: Observable<number>;
  71869. /**
  71870. * Observable raised when all material LODs of one level are loaded.
  71871. * The event data is the index of the loaded LOD starting from zero.
  71872. * Dispose the loader to cancel the loading of the next level of LODs.
  71873. */
  71874. onMaterialLODsLoadedObservable: Observable<number>;
  71875. private _loader;
  71876. private _nodeIndexLOD;
  71877. private _nodeSignalLODs;
  71878. private _nodePromiseLODs;
  71879. private _materialIndexLOD;
  71880. private _materialSignalLODs;
  71881. private _materialPromiseLODs;
  71882. private _indexLOD;
  71883. private _bufferLODs;
  71884. /** @hidden */
  71885. constructor(loader: GLTFLoader);
  71886. /** @hidden */
  71887. dispose(): void;
  71888. /** @hidden */
  71889. onReady(): void;
  71890. /** @hidden */
  71891. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  71892. /** @hidden */
  71893. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  71894. /** @hidden */
  71895. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  71896. /** @hidden */
  71897. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  71898. private _loadBufferLOD;
  71899. /**
  71900. * Gets an array of LOD properties from lowest to highest.
  71901. */
  71902. private _getLODs;
  71903. private _disposeUnusedMaterials;
  71904. }
  71905. }
  71906. declare module BABYLON.GLTF2.Loader.Extensions {
  71907. /** @hidden */
  71908. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  71909. readonly name: string;
  71910. enabled: boolean;
  71911. private _loader;
  71912. constructor(loader: GLTFLoader);
  71913. dispose(): void;
  71914. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71915. }
  71916. }
  71917. declare module BABYLON.GLTF2.Loader.Extensions {
  71918. /** @hidden */
  71919. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  71920. readonly name: string;
  71921. enabled: boolean;
  71922. private _loader;
  71923. constructor(loader: GLTFLoader);
  71924. dispose(): void;
  71925. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71926. }
  71927. }
  71928. declare module BABYLON.GLTF2.Loader.Extensions {
  71929. /**
  71930. * Store glTF extras (if present) in BJS objects' metadata
  71931. */
  71932. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  71933. /**
  71934. * The name of this extension.
  71935. */
  71936. readonly name: string;
  71937. /**
  71938. * Defines whether this extension is enabled.
  71939. */
  71940. enabled: boolean;
  71941. private _loader;
  71942. private _assignExtras;
  71943. /** @hidden */
  71944. constructor(loader: GLTFLoader);
  71945. /** @hidden */
  71946. dispose(): void;
  71947. /** @hidden */
  71948. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  71949. /** @hidden */
  71950. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  71951. /** @hidden */
  71952. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  71953. }
  71954. }
  71955. declare module BABYLON {
  71956. /**
  71957. * Class reading and parsing the MTL file bundled with the obj file.
  71958. */
  71959. export class MTLFileLoader {
  71960. /**
  71961. * All material loaded from the mtl will be set here
  71962. */
  71963. materials: StandardMaterial[];
  71964. /**
  71965. * This function will read the mtl file and create each material described inside
  71966. * This function could be improve by adding :
  71967. * -some component missing (Ni, Tf...)
  71968. * -including the specific options available
  71969. *
  71970. * @param scene defines the scene the material will be created in
  71971. * @param data defines the mtl data to parse
  71972. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  71973. */
  71974. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  71975. /**
  71976. * Gets the texture for the material.
  71977. *
  71978. * If the material is imported from input file,
  71979. * We sanitize the url to ensure it takes the textre from aside the material.
  71980. *
  71981. * @param rootUrl The root url to load from
  71982. * @param value The value stored in the mtl
  71983. * @return The Texture
  71984. */
  71985. private static _getTexture;
  71986. }
  71987. /**
  71988. * Options for loading OBJ/MTL files
  71989. */
  71990. type MeshLoadOptions = {
  71991. /**
  71992. * Defines if UVs are optimized by default during load.
  71993. */
  71994. OptimizeWithUV: boolean;
  71995. /**
  71996. * Defines custom scaling of UV coordinates of loaded meshes.
  71997. */
  71998. UVScaling: Vector2;
  71999. /**
  72000. * Invert model on y-axis (does a model scaling inversion)
  72001. */
  72002. InvertY: boolean;
  72003. /**
  72004. * Invert Y-Axis of referenced textures on load
  72005. */
  72006. InvertTextureY: boolean;
  72007. /**
  72008. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  72009. */
  72010. ImportVertexColors: boolean;
  72011. /**
  72012. * Compute the normals for the model, even if normals are present in the file.
  72013. */
  72014. ComputeNormals: boolean;
  72015. /**
  72016. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  72017. */
  72018. SkipMaterials: boolean;
  72019. /**
  72020. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  72021. */
  72022. MaterialLoadingFailsSilently: boolean;
  72023. };
  72024. /**
  72025. * OBJ file type loader.
  72026. * This is a babylon scene loader plugin.
  72027. */
  72028. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  72029. /**
  72030. * Defines if UVs are optimized by default during load.
  72031. */
  72032. static OPTIMIZE_WITH_UV: boolean;
  72033. /**
  72034. * Invert model on y-axis (does a model scaling inversion)
  72035. */
  72036. static INVERT_Y: boolean;
  72037. /**
  72038. * Invert Y-Axis of referenced textures on load
  72039. */
  72040. static INVERT_TEXTURE_Y: boolean;
  72041. /**
  72042. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  72043. */
  72044. static IMPORT_VERTEX_COLORS: boolean;
  72045. /**
  72046. * Compute the normals for the model, even if normals are present in the file.
  72047. */
  72048. static COMPUTE_NORMALS: boolean;
  72049. /**
  72050. * Defines custom scaling of UV coordinates of loaded meshes.
  72051. */
  72052. static UV_SCALING: Vector2;
  72053. /**
  72054. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  72055. */
  72056. static SKIP_MATERIALS: boolean;
  72057. /**
  72058. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  72059. *
  72060. * Defaults to true for backwards compatibility.
  72061. */
  72062. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  72063. /**
  72064. * Defines the name of the plugin.
  72065. */
  72066. name: string;
  72067. /**
  72068. * Defines the extension the plugin is able to load.
  72069. */
  72070. extensions: string;
  72071. /** @hidden */
  72072. obj: RegExp;
  72073. /** @hidden */
  72074. group: RegExp;
  72075. /** @hidden */
  72076. mtllib: RegExp;
  72077. /** @hidden */
  72078. usemtl: RegExp;
  72079. /** @hidden */
  72080. smooth: RegExp;
  72081. /** @hidden */
  72082. vertexPattern: RegExp;
  72083. /** @hidden */
  72084. normalPattern: RegExp;
  72085. /** @hidden */
  72086. uvPattern: RegExp;
  72087. /** @hidden */
  72088. facePattern1: RegExp;
  72089. /** @hidden */
  72090. facePattern2: RegExp;
  72091. /** @hidden */
  72092. facePattern3: RegExp;
  72093. /** @hidden */
  72094. facePattern4: RegExp;
  72095. /** @hidden */
  72096. facePattern5: RegExp;
  72097. private _meshLoadOptions;
  72098. /**
  72099. * Creates loader for .OBJ files
  72100. *
  72101. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  72102. */
  72103. constructor(meshLoadOptions?: MeshLoadOptions);
  72104. private static readonly currentMeshLoadOptions;
  72105. /**
  72106. * Calls synchronously the MTL file attached to this obj.
  72107. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  72108. * Without this function materials are not displayed in the first frame (but displayed after).
  72109. * In consequence it is impossible to get material information in your HTML file
  72110. *
  72111. * @param url The URL of the MTL file
  72112. * @param rootUrl
  72113. * @param onSuccess Callback function to be called when the MTL file is loaded
  72114. * @private
  72115. */
  72116. private _loadMTL;
  72117. /**
  72118. * Instantiates a OBJ file loader plugin.
  72119. * @returns the created plugin
  72120. */
  72121. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  72122. /**
  72123. * If the data string can be loaded directly.
  72124. *
  72125. * @param data string containing the file data
  72126. * @returns if the data can be loaded directly
  72127. */
  72128. canDirectLoad(data: string): boolean;
  72129. /**
  72130. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  72131. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  72132. * @param scene the scene the meshes should be added to
  72133. * @param data the OBJ data to load
  72134. * @param rootUrl root url to load from
  72135. * @param onProgress event that fires when loading progress has occured
  72136. * @param fileName Defines the name of the file to load
  72137. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  72138. */
  72139. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  72140. meshes: AbstractMesh[];
  72141. particleSystems: IParticleSystem[];
  72142. skeletons: Skeleton[];
  72143. animationGroups: AnimationGroup[];
  72144. }>;
  72145. /**
  72146. * Imports all objects from the loaded OBJ data and adds them to the scene
  72147. * @param scene the scene the objects should be added to
  72148. * @param data the OBJ data to load
  72149. * @param rootUrl root url to load from
  72150. * @param onProgress event that fires when loading progress has occured
  72151. * @param fileName Defines the name of the file to load
  72152. * @returns a promise which completes when objects have been loaded to the scene
  72153. */
  72154. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  72155. /**
  72156. * Load into an asset container.
  72157. * @param scene The scene to load into
  72158. * @param data The data to import
  72159. * @param rootUrl The root url for scene and resources
  72160. * @param onProgress The callback when the load progresses
  72161. * @param fileName Defines the name of the file to load
  72162. * @returns The loaded asset container
  72163. */
  72164. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  72165. /**
  72166. * Read the OBJ file and create an Array of meshes.
  72167. * Each mesh contains all information given by the OBJ and the MTL file.
  72168. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  72169. *
  72170. * @param meshesNames
  72171. * @param scene Scene The scene where are displayed the data
  72172. * @param data String The content of the obj file
  72173. * @param rootUrl String The path to the folder
  72174. * @returns Array<AbstractMesh>
  72175. * @private
  72176. */
  72177. private _parseSolid;
  72178. }
  72179. }
  72180. declare module BABYLON {
  72181. /**
  72182. * STL file type loader.
  72183. * This is a babylon scene loader plugin.
  72184. */
  72185. export class STLFileLoader implements ISceneLoaderPlugin {
  72186. /** @hidden */
  72187. solidPattern: RegExp;
  72188. /** @hidden */
  72189. facetsPattern: RegExp;
  72190. /** @hidden */
  72191. normalPattern: RegExp;
  72192. /** @hidden */
  72193. vertexPattern: RegExp;
  72194. /**
  72195. * Defines the name of the plugin.
  72196. */
  72197. name: string;
  72198. /**
  72199. * Defines the extensions the stl loader is able to load.
  72200. * force data to come in as an ArrayBuffer
  72201. * we'll convert to string if it looks like it's an ASCII .stl
  72202. */
  72203. extensions: ISceneLoaderPluginExtensions;
  72204. /**
  72205. * Import meshes into a scene.
  72206. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  72207. * @param scene The scene to import into
  72208. * @param data The data to import
  72209. * @param rootUrl The root url for scene and resources
  72210. * @param meshes The meshes array to import into
  72211. * @param particleSystems The particle systems array to import into
  72212. * @param skeletons The skeletons array to import into
  72213. * @param onError The callback when import fails
  72214. * @returns True if successful or false otherwise
  72215. */
  72216. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  72217. /**
  72218. * Load into a scene.
  72219. * @param scene The scene to load into
  72220. * @param data The data to import
  72221. * @param rootUrl The root url for scene and resources
  72222. * @param onError The callback when import fails
  72223. * @returns true if successful or false otherwise
  72224. */
  72225. load(scene: Scene, data: any, rootUrl: string): boolean;
  72226. /**
  72227. * Load into an asset container.
  72228. * @param scene The scene to load into
  72229. * @param data The data to import
  72230. * @param rootUrl The root url for scene and resources
  72231. * @param onError The callback when import fails
  72232. * @returns The loaded asset container
  72233. */
  72234. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  72235. private _isBinary;
  72236. private _parseBinary;
  72237. private _parseASCII;
  72238. }
  72239. }
  72240. declare module BABYLON {
  72241. /**
  72242. * Class for generating OBJ data from a Babylon scene.
  72243. */
  72244. export class OBJExport {
  72245. /**
  72246. * Exports the geometry of a Mesh array in .OBJ file format (text)
  72247. * @param mesh defines the list of meshes to serialize
  72248. * @param materials defines if materials should be exported
  72249. * @param matlibname defines the name of the associated mtl file
  72250. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  72251. * @returns the OBJ content
  72252. */
  72253. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  72254. /**
  72255. * Exports the material(s) of a mesh in .MTL file format (text)
  72256. * @param mesh defines the mesh to extract the material from
  72257. * @returns the mtl content
  72258. */
  72259. static MTL(mesh: Mesh): string;
  72260. }
  72261. }
  72262. declare module BABYLON {
  72263. /** @hidden */
  72264. export var __IGLTFExporterExtension: number;
  72265. /**
  72266. * Interface for extending the exporter
  72267. * @hidden
  72268. */
  72269. export interface IGLTFExporterExtension {
  72270. /**
  72271. * The name of this extension
  72272. */
  72273. readonly name: string;
  72274. /**
  72275. * Defines whether this extension is enabled
  72276. */
  72277. enabled: boolean;
  72278. /**
  72279. * Defines whether this extension is required
  72280. */
  72281. required: boolean;
  72282. }
  72283. }
  72284. declare module BABYLON.GLTF2.Exporter {
  72285. /** @hidden */
  72286. export var __IGLTFExporterExtensionV2: number;
  72287. /**
  72288. * Interface for a glTF exporter extension
  72289. * @hidden
  72290. */
  72291. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  72292. /**
  72293. * Define this method to modify the default behavior before exporting a texture
  72294. * @param context The context when loading the asset
  72295. * @param babylonTexture The Babylon.js texture
  72296. * @param mimeType The mime-type of the generated image
  72297. * @returns A promise that resolves with the exported texture
  72298. */
  72299. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  72300. /**
  72301. * Define this method to get notified when a texture info is created
  72302. * @param context The context when loading the asset
  72303. * @param textureInfo The glTF texture info
  72304. * @param babylonTexture The Babylon.js texture
  72305. */
  72306. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  72307. /**
  72308. * Define this method to modify the default behavior when exporting texture info
  72309. * @param context The context when loading the asset
  72310. * @param meshPrimitive glTF mesh primitive
  72311. * @param babylonSubMesh Babylon submesh
  72312. * @param binaryWriter glTF serializer binary writer instance
  72313. * @returns nullable IMeshPrimitive promise
  72314. */
  72315. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  72316. /**
  72317. * Define this method to modify the default behavior when exporting a node
  72318. * @param context The context when exporting the node
  72319. * @param node glTF node
  72320. * @param babylonNode BabylonJS node
  72321. * @returns nullable INode promise
  72322. */
  72323. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Promise<INode>;
  72324. /**
  72325. * Define this method to modify the default behavior when exporting a material
  72326. * @param material glTF material
  72327. * @param babylonMaterial BabylonJS material
  72328. * @returns nullable IMaterial promise
  72329. */
  72330. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  72331. /**
  72332. * Define this method to return additional textures to export from a material
  72333. * @param material glTF material
  72334. * @param babylonMaterial BabylonJS material
  72335. * @returns List of textures
  72336. */
  72337. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  72338. /** Gets a boolean indicating that this extension was used */
  72339. wasUsed: boolean;
  72340. /** Gets a boolean indicating that this extension is required for the file to work */
  72341. required: boolean;
  72342. /**
  72343. * Called after the exporter state changes to EXPORTING
  72344. */
  72345. onExporting?(): void;
  72346. }
  72347. }
  72348. declare module BABYLON.GLTF2.Exporter {
  72349. /**
  72350. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  72351. * @hidden
  72352. */
  72353. export class _GLTFMaterialExporter {
  72354. /**
  72355. * Represents the dielectric specular values for R, G and B
  72356. */
  72357. private static readonly _DielectricSpecular;
  72358. /**
  72359. * Allows the maximum specular power to be defined for material calculations
  72360. */
  72361. private static readonly _MaxSpecularPower;
  72362. /**
  72363. * Mapping to store textures
  72364. */
  72365. private _textureMap;
  72366. /**
  72367. * Numeric tolerance value
  72368. */
  72369. private static readonly _Epsilon;
  72370. /**
  72371. * Reference to the glTF Exporter
  72372. */
  72373. private _exporter;
  72374. constructor(exporter: _Exporter);
  72375. /**
  72376. * Specifies if two colors are approximately equal in value
  72377. * @param color1 first color to compare to
  72378. * @param color2 second color to compare to
  72379. * @param epsilon threshold value
  72380. */
  72381. private static FuzzyEquals;
  72382. /**
  72383. * Gets the materials from a Babylon scene and converts them to glTF materials
  72384. * @param scene babylonjs scene
  72385. * @param mimeType texture mime type
  72386. * @param images array of images
  72387. * @param textures array of textures
  72388. * @param materials array of materials
  72389. * @param imageData mapping of texture names to base64 textures
  72390. * @param hasTextureCoords specifies if texture coordinates are present on the material
  72391. */
  72392. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  72393. /**
  72394. * Makes a copy of the glTF material without the texture parameters
  72395. * @param originalMaterial original glTF material
  72396. * @returns glTF material without texture parameters
  72397. */
  72398. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  72399. /**
  72400. * Specifies if the material has any texture parameters present
  72401. * @param material glTF Material
  72402. * @returns boolean specifying if texture parameters are present
  72403. */
  72404. _hasTexturesPresent(material: IMaterial): boolean;
  72405. /**
  72406. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  72407. * @param babylonStandardMaterial
  72408. * @returns glTF Metallic Roughness Material representation
  72409. */
  72410. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  72411. /**
  72412. * Computes the metallic factor
  72413. * @param diffuse diffused value
  72414. * @param specular specular value
  72415. * @param oneMinusSpecularStrength one minus the specular strength
  72416. * @returns metallic value
  72417. */
  72418. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  72419. /**
  72420. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  72421. * @param glTFMaterial glTF material
  72422. * @param babylonMaterial Babylon material
  72423. */
  72424. private static _SetAlphaMode;
  72425. /**
  72426. * Converts a Babylon Standard Material to a glTF Material
  72427. * @param babylonStandardMaterial BJS Standard Material
  72428. * @param mimeType mime type to use for the textures
  72429. * @param images array of glTF image interfaces
  72430. * @param textures array of glTF texture interfaces
  72431. * @param materials array of glTF material interfaces
  72432. * @param imageData map of image file name to data
  72433. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  72434. */
  72435. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  72436. private _finishMaterial;
  72437. /**
  72438. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  72439. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  72440. * @param mimeType mime type to use for the textures
  72441. * @param images array of glTF image interfaces
  72442. * @param textures array of glTF texture interfaces
  72443. * @param materials array of glTF material interfaces
  72444. * @param imageData map of image file name to data
  72445. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  72446. */
  72447. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  72448. /**
  72449. * Converts an image typed array buffer to a base64 image
  72450. * @param buffer typed array buffer
  72451. * @param width width of the image
  72452. * @param height height of the image
  72453. * @param mimeType mimetype of the image
  72454. * @returns base64 image string
  72455. */
  72456. private _createBase64FromCanvasAsync;
  72457. /**
  72458. * Generates a white texture based on the specified width and height
  72459. * @param width width of the texture in pixels
  72460. * @param height height of the texture in pixels
  72461. * @param scene babylonjs scene
  72462. * @returns white texture
  72463. */
  72464. private _createWhiteTexture;
  72465. /**
  72466. * 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
  72467. * @param texture1 first texture to resize
  72468. * @param texture2 second texture to resize
  72469. * @param scene babylonjs scene
  72470. * @returns resized textures or null
  72471. */
  72472. private _resizeTexturesToSameDimensions;
  72473. /**
  72474. * Converts an array of pixels to a Float32Array
  72475. * Throws an error if the pixel format is not supported
  72476. * @param pixels - array buffer containing pixel values
  72477. * @returns Float32 of pixels
  72478. */
  72479. private _convertPixelArrayToFloat32;
  72480. /**
  72481. * Convert Specular Glossiness Textures to Metallic Roughness
  72482. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  72483. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  72484. * @param diffuseTexture texture used to store diffuse information
  72485. * @param specularGlossinessTexture texture used to store specular and glossiness information
  72486. * @param factors specular glossiness material factors
  72487. * @param mimeType the mime type to use for the texture
  72488. * @returns pbr metallic roughness interface or null
  72489. */
  72490. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  72491. /**
  72492. * Converts specular glossiness material properties to metallic roughness
  72493. * @param specularGlossiness interface with specular glossiness material properties
  72494. * @returns interface with metallic roughness material properties
  72495. */
  72496. private _convertSpecularGlossinessToMetallicRoughness;
  72497. /**
  72498. * Calculates the surface reflectance, independent of lighting conditions
  72499. * @param color Color source to calculate brightness from
  72500. * @returns number representing the perceived brightness, or zero if color is undefined
  72501. */
  72502. private _getPerceivedBrightness;
  72503. /**
  72504. * Returns the maximum color component value
  72505. * @param color
  72506. * @returns maximum color component value, or zero if color is null or undefined
  72507. */
  72508. private _getMaxComponent;
  72509. /**
  72510. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  72511. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  72512. * @param mimeType mime type to use for the textures
  72513. * @param images array of glTF image interfaces
  72514. * @param textures array of glTF texture interfaces
  72515. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  72516. * @param imageData map of image file name to data
  72517. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  72518. * @returns glTF PBR Metallic Roughness factors
  72519. */
  72520. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  72521. private _getGLTFTextureSampler;
  72522. private _getGLTFTextureWrapMode;
  72523. private _getGLTFTextureWrapModesSampler;
  72524. /**
  72525. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  72526. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  72527. * @param mimeType mime type to use for the textures
  72528. * @param images array of glTF image interfaces
  72529. * @param textures array of glTF texture interfaces
  72530. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  72531. * @param imageData map of image file name to data
  72532. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  72533. * @returns glTF PBR Metallic Roughness factors
  72534. */
  72535. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  72536. /**
  72537. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  72538. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  72539. * @param mimeType mime type to use for the textures
  72540. * @param images array of glTF image interfaces
  72541. * @param textures array of glTF texture interfaces
  72542. * @param materials array of glTF material interfaces
  72543. * @param imageData map of image file name to data
  72544. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  72545. */
  72546. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  72547. private setMetallicRoughnessPbrMaterial;
  72548. private getPixelsFromTexture;
  72549. /**
  72550. * Extracts a texture from a Babylon texture into file data and glTF data
  72551. * @param babylonTexture Babylon texture to extract
  72552. * @param mimeType Mime Type of the babylonTexture
  72553. * @return glTF texture info, or null if the texture format is not supported
  72554. */
  72555. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  72556. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  72557. /**
  72558. * Builds a texture from base64 string
  72559. * @param base64Texture base64 texture string
  72560. * @param baseTextureName Name to use for the texture
  72561. * @param mimeType image mime type for the texture
  72562. * @param images array of images
  72563. * @param textures array of textures
  72564. * @param imageData map of image data
  72565. * @returns glTF texture info, or null if the texture format is not supported
  72566. */
  72567. private _getTextureInfoFromBase64;
  72568. }
  72569. }
  72570. declare module BABYLON {
  72571. /**
  72572. * Class for holding and downloading glTF file data
  72573. */
  72574. export class GLTFData {
  72575. /**
  72576. * Object which contains the file name as the key and its data as the value
  72577. */
  72578. glTFFiles: {
  72579. [fileName: string]: string | Blob;
  72580. };
  72581. /**
  72582. * Initializes the glTF file object
  72583. */
  72584. constructor();
  72585. /**
  72586. * Downloads the glTF data as files based on their names and data
  72587. */
  72588. downloadFiles(): void;
  72589. }
  72590. }
  72591. declare module BABYLON {
  72592. /**
  72593. * Holds a collection of exporter options and parameters
  72594. */
  72595. export interface IExportOptions {
  72596. /**
  72597. * Function which indicates whether a babylon node should be exported or not
  72598. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  72599. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  72600. */
  72601. shouldExportNode?(node: Node): boolean;
  72602. /**
  72603. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  72604. * @param metadata source metadata to read from
  72605. * @returns the data to store to glTF node extras
  72606. */
  72607. metadataSelector?(metadata: any): any;
  72608. /**
  72609. * The sample rate to bake animation curves
  72610. */
  72611. animationSampleRate?: number;
  72612. /**
  72613. * Begin serialization without waiting for the scene to be ready
  72614. */
  72615. exportWithoutWaitingForScene?: boolean;
  72616. }
  72617. /**
  72618. * Class for generating glTF data from a Babylon scene.
  72619. */
  72620. export class GLTF2Export {
  72621. /**
  72622. * Exports the geometry of the scene to .gltf file format asynchronously
  72623. * @param scene Babylon scene with scene hierarchy information
  72624. * @param filePrefix File prefix to use when generating the glTF file
  72625. * @param options Exporter options
  72626. * @returns Returns an object with a .gltf file and associates texture names
  72627. * as keys and their data and paths as values
  72628. */
  72629. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  72630. private static _PreExportAsync;
  72631. private static _PostExportAsync;
  72632. /**
  72633. * Exports the geometry of the scene to .glb file format asychronously
  72634. * @param scene Babylon scene with scene hierarchy information
  72635. * @param filePrefix File prefix to use when generating glb file
  72636. * @param options Exporter options
  72637. * @returns Returns an object with a .glb filename as key and data as value
  72638. */
  72639. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  72640. }
  72641. }
  72642. declare module BABYLON.GLTF2.Exporter {
  72643. /**
  72644. * @hidden
  72645. */
  72646. export class _GLTFUtilities {
  72647. /**
  72648. * Creates a buffer view based on the supplied arguments
  72649. * @param bufferIndex index value of the specified buffer
  72650. * @param byteOffset byte offset value
  72651. * @param byteLength byte length of the bufferView
  72652. * @param byteStride byte distance between conequential elements
  72653. * @param name name of the buffer view
  72654. * @returns bufferView for glTF
  72655. */
  72656. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  72657. /**
  72658. * Creates an accessor based on the supplied arguments
  72659. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  72660. * @param name The name of the accessor
  72661. * @param type The type of the accessor
  72662. * @param componentType The datatype of components in the attribute
  72663. * @param count The number of attributes referenced by this accessor
  72664. * @param byteOffset The offset relative to the start of the bufferView in bytes
  72665. * @param min Minimum value of each component in this attribute
  72666. * @param max Maximum value of each component in this attribute
  72667. * @returns accessor for glTF
  72668. */
  72669. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  72670. /**
  72671. * Calculates the minimum and maximum values of an array of position floats
  72672. * @param positions Positions array of a mesh
  72673. * @param vertexStart Starting vertex offset to calculate min and max values
  72674. * @param vertexCount Number of vertices to check for min and max values
  72675. * @returns min number array and max number array
  72676. */
  72677. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  72678. min: number[];
  72679. max: number[];
  72680. };
  72681. /**
  72682. * Converts a new right-handed Vector3
  72683. * @param vector vector3 array
  72684. * @returns right-handed Vector3
  72685. */
  72686. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  72687. /**
  72688. * Converts a Vector3 to right-handed
  72689. * @param vector Vector3 to convert to right-handed
  72690. */
  72691. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  72692. /**
  72693. * Converts a three element number array to right-handed
  72694. * @param vector number array to convert to right-handed
  72695. */
  72696. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  72697. /**
  72698. * Converts a new right-handed Vector3
  72699. * @param vector vector3 array
  72700. * @returns right-handed Vector3
  72701. */
  72702. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  72703. /**
  72704. * Converts a Vector3 to right-handed
  72705. * @param vector Vector3 to convert to right-handed
  72706. */
  72707. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  72708. /**
  72709. * Converts a three element number array to right-handed
  72710. * @param vector number array to convert to right-handed
  72711. */
  72712. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  72713. /**
  72714. * Converts a Vector4 to right-handed
  72715. * @param vector Vector4 to convert to right-handed
  72716. */
  72717. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  72718. /**
  72719. * Converts a Vector4 to right-handed
  72720. * @param vector Vector4 to convert to right-handed
  72721. */
  72722. static _GetRightHandedArray4FromRef(vector: number[]): void;
  72723. /**
  72724. * Converts a Quaternion to right-handed
  72725. * @param quaternion Source quaternion to convert to right-handed
  72726. */
  72727. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  72728. /**
  72729. * Converts a Quaternion to right-handed
  72730. * @param quaternion Source quaternion to convert to right-handed
  72731. */
  72732. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  72733. static _NormalizeTangentFromRef(tangent: Vector4): void;
  72734. }
  72735. }
  72736. declare module BABYLON.GLTF2.Exporter {
  72737. /**
  72738. * Converts Babylon Scene into glTF 2.0.
  72739. * @hidden
  72740. */
  72741. export class _Exporter {
  72742. /**
  72743. * Stores the glTF to export
  72744. */
  72745. _glTF: IGLTF;
  72746. /**
  72747. * Stores all generated buffer views, which represents views into the main glTF buffer data
  72748. */
  72749. _bufferViews: IBufferView[];
  72750. /**
  72751. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  72752. */
  72753. _accessors: IAccessor[];
  72754. /**
  72755. * Stores all the generated nodes, which contains transform and/or mesh information per node
  72756. */
  72757. private _nodes;
  72758. /**
  72759. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  72760. */
  72761. private _scenes;
  72762. /**
  72763. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  72764. */
  72765. private _meshes;
  72766. /**
  72767. * Stores all the generated material information, which represents the appearance of each primitive
  72768. */
  72769. _materials: IMaterial[];
  72770. _materialMap: {
  72771. [materialID: number]: number;
  72772. };
  72773. /**
  72774. * Stores all the generated texture information, which is referenced by glTF materials
  72775. */
  72776. _textures: ITexture[];
  72777. /**
  72778. * Stores all the generated image information, which is referenced by glTF textures
  72779. */
  72780. _images: IImage[];
  72781. /**
  72782. * Stores all the texture samplers
  72783. */
  72784. _samplers: ISampler[];
  72785. /**
  72786. * Stores all the generated animation samplers, which is referenced by glTF animations
  72787. */
  72788. /**
  72789. * Stores the animations for glTF models
  72790. */
  72791. private _animations;
  72792. /**
  72793. * Stores the total amount of bytes stored in the glTF buffer
  72794. */
  72795. private _totalByteLength;
  72796. /**
  72797. * Stores a reference to the Babylon scene containing the source geometry and material information
  72798. */
  72799. _babylonScene: Scene;
  72800. /**
  72801. * Stores a map of the image data, where the key is the file name and the value
  72802. * is the image data
  72803. */
  72804. _imageData: {
  72805. [fileName: string]: {
  72806. data: Uint8Array;
  72807. mimeType: ImageMimeType;
  72808. };
  72809. };
  72810. /**
  72811. * Stores a map of the unique id of a node to its index in the node array
  72812. */
  72813. private _nodeMap;
  72814. /**
  72815. * Specifies if the Babylon scene should be converted to right-handed on export
  72816. */
  72817. _convertToRightHandedSystem: boolean;
  72818. /**
  72819. * Baked animation sample rate
  72820. */
  72821. private _animationSampleRate;
  72822. private _options;
  72823. private _localEngine;
  72824. _glTFMaterialExporter: _GLTFMaterialExporter;
  72825. private _extensions;
  72826. private static _ExtensionNames;
  72827. private static _ExtensionFactories;
  72828. private _applyExtension;
  72829. private _applyExtensions;
  72830. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  72831. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  72832. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<Nullable<INode>>;
  72833. _extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  72834. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  72835. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  72836. private _forEachExtensions;
  72837. private _extensionsOnExporting;
  72838. /**
  72839. * Load glTF serializer extensions
  72840. */
  72841. private _loadExtensions;
  72842. /**
  72843. * Creates a glTF Exporter instance, which can accept optional exporter options
  72844. * @param babylonScene Babylon scene object
  72845. * @param options Options to modify the behavior of the exporter
  72846. */
  72847. constructor(babylonScene: Scene, options?: IExportOptions);
  72848. dispose(): void;
  72849. /**
  72850. * Registers a glTF exporter extension
  72851. * @param name Name of the extension to export
  72852. * @param factory The factory function that creates the exporter extension
  72853. */
  72854. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  72855. /**
  72856. * Un-registers an exporter extension
  72857. * @param name The name fo the exporter extension
  72858. * @returns A boolean indicating whether the extension has been un-registered
  72859. */
  72860. static UnregisterExtension(name: string): boolean;
  72861. /**
  72862. * Lazy load a local engine with premultiplied alpha set to false
  72863. */
  72864. _getLocalEngine(): Engine;
  72865. private reorderIndicesBasedOnPrimitiveMode;
  72866. /**
  72867. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  72868. * clock-wise during export to glTF
  72869. * @param submesh BabylonJS submesh
  72870. * @param primitiveMode Primitive mode of the mesh
  72871. * @param sideOrientation the winding order of the submesh
  72872. * @param vertexBufferKind The type of vertex attribute
  72873. * @param meshAttributeArray The vertex attribute data
  72874. * @param byteOffset The offset to the binary data
  72875. * @param binaryWriter The binary data for the glTF file
  72876. */
  72877. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  72878. /**
  72879. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  72880. * clock-wise during export to glTF
  72881. * @param submesh BabylonJS submesh
  72882. * @param primitiveMode Primitive mode of the mesh
  72883. * @param sideOrientation the winding order of the submesh
  72884. * @param vertexBufferKind The type of vertex attribute
  72885. * @param meshAttributeArray The vertex attribute data
  72886. * @param byteOffset The offset to the binary data
  72887. * @param binaryWriter The binary data for the glTF file
  72888. */
  72889. private reorderTriangleFillMode;
  72890. /**
  72891. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  72892. * clock-wise during export to glTF
  72893. * @param submesh BabylonJS submesh
  72894. * @param primitiveMode Primitive mode of the mesh
  72895. * @param sideOrientation the winding order of the submesh
  72896. * @param vertexBufferKind The type of vertex attribute
  72897. * @param meshAttributeArray The vertex attribute data
  72898. * @param byteOffset The offset to the binary data
  72899. * @param binaryWriter The binary data for the glTF file
  72900. */
  72901. private reorderTriangleStripDrawMode;
  72902. /**
  72903. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  72904. * clock-wise during export to glTF
  72905. * @param submesh BabylonJS submesh
  72906. * @param primitiveMode Primitive mode of the mesh
  72907. * @param sideOrientation the winding order of the submesh
  72908. * @param vertexBufferKind The type of vertex attribute
  72909. * @param meshAttributeArray The vertex attribute data
  72910. * @param byteOffset The offset to the binary data
  72911. * @param binaryWriter The binary data for the glTF file
  72912. */
  72913. private reorderTriangleFanMode;
  72914. /**
  72915. * Writes the vertex attribute data to binary
  72916. * @param vertices The vertices to write to the binary writer
  72917. * @param byteOffset The offset into the binary writer to overwrite binary data
  72918. * @param vertexAttributeKind The vertex attribute type
  72919. * @param meshAttributeArray The vertex attribute data
  72920. * @param binaryWriter The writer containing the binary data
  72921. */
  72922. private writeVertexAttributeData;
  72923. /**
  72924. * Writes mesh attribute data to a data buffer
  72925. * Returns the bytelength of the data
  72926. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  72927. * @param meshAttributeArray Array containing the attribute data
  72928. * @param binaryWriter The buffer to write the binary data to
  72929. * @param indices Used to specify the order of the vertex data
  72930. */
  72931. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  72932. /**
  72933. * Generates glTF json data
  72934. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  72935. * @param glTFPrefix Text to use when prefixing a glTF file
  72936. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  72937. * @returns json data as string
  72938. */
  72939. private generateJSON;
  72940. /**
  72941. * Generates data for .gltf and .bin files based on the glTF prefix string
  72942. * @param glTFPrefix Text to use when prefixing a glTF file
  72943. * @param dispose Dispose the exporter
  72944. * @returns GLTFData with glTF file data
  72945. */
  72946. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  72947. /**
  72948. * Creates a binary buffer for glTF
  72949. * @returns array buffer for binary data
  72950. */
  72951. private _generateBinaryAsync;
  72952. /**
  72953. * Pads the number to a multiple of 4
  72954. * @param num number to pad
  72955. * @returns padded number
  72956. */
  72957. private _getPadding;
  72958. /**
  72959. * @hidden
  72960. */
  72961. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  72962. /**
  72963. * Sets the TRS for each node
  72964. * @param node glTF Node for storing the transformation data
  72965. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  72966. */
  72967. private setNodeTransformation;
  72968. private getVertexBufferFromMesh;
  72969. /**
  72970. * Creates a bufferview based on the vertices type for the Babylon mesh
  72971. * @param kind Indicates the type of vertices data
  72972. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  72973. * @param binaryWriter The buffer to write the bufferview data to
  72974. */
  72975. private createBufferViewKind;
  72976. /**
  72977. * The primitive mode of the Babylon mesh
  72978. * @param babylonMesh The BabylonJS mesh
  72979. */
  72980. private getMeshPrimitiveMode;
  72981. /**
  72982. * Sets the primitive mode of the glTF mesh primitive
  72983. * @param meshPrimitive glTF mesh primitive
  72984. * @param primitiveMode The primitive mode
  72985. */
  72986. private setPrimitiveMode;
  72987. /**
  72988. * Sets the vertex attribute accessor based of the glTF mesh primitive
  72989. * @param meshPrimitive glTF mesh primitive
  72990. * @param attributeKind vertex attribute
  72991. * @returns boolean specifying if uv coordinates are present
  72992. */
  72993. private setAttributeKind;
  72994. /**
  72995. * Sets data for the primitive attributes of each submesh
  72996. * @param mesh glTF Mesh object to store the primitive attribute information
  72997. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  72998. * @param binaryWriter Buffer to write the attribute data to
  72999. */
  73000. private setPrimitiveAttributesAsync;
  73001. /**
  73002. * Creates a glTF scene based on the array of meshes
  73003. * Returns the the total byte offset
  73004. * @param babylonScene Babylon scene to get the mesh data from
  73005. * @param binaryWriter Buffer to write binary data to
  73006. */
  73007. private createSceneAsync;
  73008. /**
  73009. * Creates a mapping of Node unique id to node index and handles animations
  73010. * @param babylonScene Babylon Scene
  73011. * @param nodes Babylon transform nodes
  73012. * @param binaryWriter Buffer to write binary data to
  73013. * @returns Node mapping of unique id to index
  73014. */
  73015. private createNodeMapAndAnimationsAsync;
  73016. /**
  73017. * Creates a glTF node from a Babylon mesh
  73018. * @param babylonMesh Source Babylon mesh
  73019. * @param binaryWriter Buffer for storing geometry data
  73020. * @returns glTF node
  73021. */
  73022. private createNodeAsync;
  73023. }
  73024. /**
  73025. * @hidden
  73026. *
  73027. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  73028. */
  73029. export class _BinaryWriter {
  73030. /**
  73031. * Array buffer which stores all binary data
  73032. */
  73033. private _arrayBuffer;
  73034. /**
  73035. * View of the array buffer
  73036. */
  73037. private _dataView;
  73038. /**
  73039. * byte offset of data in array buffer
  73040. */
  73041. private _byteOffset;
  73042. /**
  73043. * Initialize binary writer with an initial byte length
  73044. * @param byteLength Initial byte length of the array buffer
  73045. */
  73046. constructor(byteLength: number);
  73047. /**
  73048. * Resize the array buffer to the specified byte length
  73049. * @param byteLength
  73050. */
  73051. private resizeBuffer;
  73052. /**
  73053. * Get an array buffer with the length of the byte offset
  73054. * @returns ArrayBuffer resized to the byte offset
  73055. */
  73056. getArrayBuffer(): ArrayBuffer;
  73057. /**
  73058. * Get the byte offset of the array buffer
  73059. * @returns byte offset
  73060. */
  73061. getByteOffset(): number;
  73062. /**
  73063. * Stores an UInt8 in the array buffer
  73064. * @param entry
  73065. * @param byteOffset If defined, specifies where to set the value as an offset.
  73066. */
  73067. setUInt8(entry: number, byteOffset?: number): void;
  73068. /**
  73069. * Gets an UInt32 in the array buffer
  73070. * @param entry
  73071. * @param byteOffset If defined, specifies where to set the value as an offset.
  73072. */
  73073. getUInt32(byteOffset: number): number;
  73074. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  73075. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  73076. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  73077. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  73078. /**
  73079. * Stores a Float32 in the array buffer
  73080. * @param entry
  73081. */
  73082. setFloat32(entry: number, byteOffset?: number): void;
  73083. /**
  73084. * Stores an UInt32 in the array buffer
  73085. * @param entry
  73086. * @param byteOffset If defined, specifies where to set the value as an offset.
  73087. */
  73088. setUInt32(entry: number, byteOffset?: number): void;
  73089. }
  73090. }
  73091. declare module BABYLON.GLTF2.Exporter {
  73092. /**
  73093. * @hidden
  73094. * Interface to store animation data.
  73095. */
  73096. export interface _IAnimationData {
  73097. /**
  73098. * Keyframe data.
  73099. */
  73100. inputs: number[];
  73101. /**
  73102. * Value data.
  73103. */
  73104. outputs: number[][];
  73105. /**
  73106. * Animation interpolation data.
  73107. */
  73108. samplerInterpolation: AnimationSamplerInterpolation;
  73109. /**
  73110. * Minimum keyframe value.
  73111. */
  73112. inputsMin: number;
  73113. /**
  73114. * Maximum keyframe value.
  73115. */
  73116. inputsMax: number;
  73117. }
  73118. /**
  73119. * @hidden
  73120. */
  73121. export interface _IAnimationInfo {
  73122. /**
  73123. * The target channel for the animation
  73124. */
  73125. animationChannelTargetPath: AnimationChannelTargetPath;
  73126. /**
  73127. * The glTF accessor type for the data.
  73128. */
  73129. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  73130. /**
  73131. * Specifies if quaternions should be used.
  73132. */
  73133. useQuaternion: boolean;
  73134. }
  73135. /**
  73136. * @hidden
  73137. * Utility class for generating glTF animation data from BabylonJS.
  73138. */
  73139. export class _GLTFAnimation {
  73140. /**
  73141. * @ignore
  73142. *
  73143. * Creates glTF channel animation from BabylonJS animation.
  73144. * @param babylonTransformNode - BabylonJS mesh.
  73145. * @param animation - animation.
  73146. * @param animationChannelTargetPath - The target animation channel.
  73147. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  73148. * @param useQuaternion - Specifies if quaternions are used.
  73149. * @returns nullable IAnimationData
  73150. */
  73151. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  73152. private static _DeduceAnimationInfo;
  73153. /**
  73154. * @ignore
  73155. * Create node animations from the transform node animations
  73156. * @param babylonNode
  73157. * @param runtimeGLTFAnimation
  73158. * @param idleGLTFAnimations
  73159. * @param nodeMap
  73160. * @param nodes
  73161. * @param binaryWriter
  73162. * @param bufferViews
  73163. * @param accessors
  73164. * @param convertToRightHandedSystem
  73165. */
  73166. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  73167. [key: number]: number;
  73168. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  73169. /**
  73170. * @ignore
  73171. * Create node animations from the animation groups
  73172. * @param babylonScene
  73173. * @param glTFAnimations
  73174. * @param nodeMap
  73175. * @param nodes
  73176. * @param binaryWriter
  73177. * @param bufferViews
  73178. * @param accessors
  73179. * @param convertToRightHandedSystem
  73180. */
  73181. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  73182. [key: number]: number;
  73183. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  73184. private static AddAnimation;
  73185. /**
  73186. * Create a baked animation
  73187. * @param babylonTransformNode BabylonJS mesh
  73188. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  73189. * @param animationChannelTargetPath animation target channel
  73190. * @param minFrame minimum animation frame
  73191. * @param maxFrame maximum animation frame
  73192. * @param fps frames per second of the animation
  73193. * @param inputs input key frames of the animation
  73194. * @param outputs output key frame data of the animation
  73195. * @param convertToRightHandedSystem converts the values to right-handed
  73196. * @param useQuaternion specifies if quaternions should be used
  73197. */
  73198. private static _CreateBakedAnimation;
  73199. private static _ConvertFactorToVector3OrQuaternion;
  73200. private static _SetInterpolatedValue;
  73201. /**
  73202. * Creates linear animation from the animation key frames
  73203. * @param babylonTransformNode BabylonJS mesh
  73204. * @param animation BabylonJS animation
  73205. * @param animationChannelTargetPath The target animation channel
  73206. * @param frameDelta The difference between the last and first frame of the animation
  73207. * @param inputs Array to store the key frame times
  73208. * @param outputs Array to store the key frame data
  73209. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  73210. * @param useQuaternion Specifies if quaternions are used in the animation
  73211. */
  73212. private static _CreateLinearOrStepAnimation;
  73213. /**
  73214. * Creates cubic spline animation from the animation key frames
  73215. * @param babylonTransformNode BabylonJS mesh
  73216. * @param animation BabylonJS animation
  73217. * @param animationChannelTargetPath The target animation channel
  73218. * @param frameDelta The difference between the last and first frame of the animation
  73219. * @param inputs Array to store the key frame times
  73220. * @param outputs Array to store the key frame data
  73221. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  73222. * @param useQuaternion Specifies if quaternions are used in the animation
  73223. */
  73224. private static _CreateCubicSplineAnimation;
  73225. private static _GetBasePositionRotationOrScale;
  73226. /**
  73227. * Adds a key frame value
  73228. * @param keyFrame
  73229. * @param animation
  73230. * @param outputs
  73231. * @param animationChannelTargetPath
  73232. * @param basePositionRotationOrScale
  73233. * @param convertToRightHandedSystem
  73234. * @param useQuaternion
  73235. */
  73236. private static _AddKeyframeValue;
  73237. /**
  73238. * Determine the interpolation based on the key frames
  73239. * @param keyFrames
  73240. * @param animationChannelTargetPath
  73241. * @param useQuaternion
  73242. */
  73243. private static _DeduceInterpolation;
  73244. /**
  73245. * Adds an input tangent or output tangent to the output data
  73246. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  73247. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  73248. * @param outputs The animation data by keyframe
  73249. * @param animationChannelTargetPath The target animation channel
  73250. * @param interpolation The interpolation type
  73251. * @param keyFrame The key frame with the animation data
  73252. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  73253. * @param useQuaternion Specifies if quaternions are used
  73254. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  73255. */
  73256. private static AddSplineTangent;
  73257. /**
  73258. * Get the minimum and maximum key frames' frame values
  73259. * @param keyFrames animation key frames
  73260. * @returns the minimum and maximum key frame value
  73261. */
  73262. private static calculateMinMaxKeyFrames;
  73263. }
  73264. }
  73265. declare module BABYLON.GLTF2.Exporter {
  73266. /** @hidden */
  73267. export var textureTransformPixelShader: {
  73268. name: string;
  73269. shader: string;
  73270. };
  73271. }
  73272. declare module BABYLON.GLTF2.Exporter.Extensions {
  73273. /**
  73274. * @hidden
  73275. */
  73276. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  73277. private _recordedTextures;
  73278. /** Name of this extension */
  73279. readonly name: string;
  73280. /** Defines whether this extension is enabled */
  73281. enabled: boolean;
  73282. /** Defines whether this extension is required */
  73283. required: boolean;
  73284. /** Reference to the glTF exporter */
  73285. private _wasUsed;
  73286. constructor(exporter: _Exporter);
  73287. dispose(): void;
  73288. /** @hidden */
  73289. readonly wasUsed: boolean;
  73290. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  73291. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  73292. /**
  73293. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  73294. * @param babylonTexture
  73295. * @param offset
  73296. * @param rotation
  73297. * @param scale
  73298. * @param scene
  73299. */
  73300. private _textureTransformTextureAsync;
  73301. }
  73302. }
  73303. declare module BABYLON.GLTF2.Exporter.Extensions {
  73304. /**
  73305. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  73306. */
  73307. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  73308. /** The name of this extension. */
  73309. readonly name: string;
  73310. /** Defines whether this extension is enabled. */
  73311. enabled: boolean;
  73312. /** Defines whether this extension is required */
  73313. required: boolean;
  73314. /** Reference to the glTF exporter */
  73315. private _exporter;
  73316. private _lights;
  73317. /** @hidden */
  73318. constructor(exporter: _Exporter);
  73319. /** @hidden */
  73320. dispose(): void;
  73321. /** @hidden */
  73322. readonly wasUsed: boolean;
  73323. /** @hidden */
  73324. onExporting(): void;
  73325. /**
  73326. * Define this method to modify the default behavior when exporting a node
  73327. * @param context The context when exporting the node
  73328. * @param node glTF node
  73329. * @param babylonNode BabylonJS node
  73330. * @returns nullable INode promise
  73331. */
  73332. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<INode>;
  73333. }
  73334. }
  73335. declare module BABYLON.GLTF2.Exporter.Extensions {
  73336. /**
  73337. * @hidden
  73338. */
  73339. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  73340. /** Name of this extension */
  73341. readonly name: string;
  73342. /** Defines whether this extension is enabled */
  73343. enabled: boolean;
  73344. /** Defines whether this extension is required */
  73345. required: boolean;
  73346. /** Reference to the glTF exporter */
  73347. private _textureInfos;
  73348. private _exportedTextures;
  73349. private _wasUsed;
  73350. constructor(exporter: _Exporter);
  73351. dispose(): void;
  73352. /** @hidden */
  73353. readonly wasUsed: boolean;
  73354. private _getTextureIndex;
  73355. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  73356. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  73357. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  73358. }
  73359. }
  73360. declare module BABYLON {
  73361. /**
  73362. * Class for generating STL data from a Babylon scene.
  73363. */
  73364. export class STLExport {
  73365. /**
  73366. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  73367. * @param meshes list defines the mesh to serialize
  73368. * @param download triggers the automatic download of the file.
  73369. * @param fileName changes the downloads fileName.
  73370. * @param binary changes the STL to a binary type.
  73371. * @param isLittleEndian toggle for binary type exporter.
  73372. * @returns the STL as UTF8 string
  73373. */
  73374. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  73375. }
  73376. }
  73377. declare module "babylonjs-gltf2interface" {
  73378. export = BABYLON.GLTF2;
  73379. }
  73380. /**
  73381. * Module for glTF 2.0 Interface
  73382. */
  73383. declare module BABYLON.GLTF2 {
  73384. /**
  73385. * The datatype of the components in the attribute
  73386. */
  73387. const enum AccessorComponentType {
  73388. /**
  73389. * Byte
  73390. */
  73391. BYTE = 5120,
  73392. /**
  73393. * Unsigned Byte
  73394. */
  73395. UNSIGNED_BYTE = 5121,
  73396. /**
  73397. * Short
  73398. */
  73399. SHORT = 5122,
  73400. /**
  73401. * Unsigned Short
  73402. */
  73403. UNSIGNED_SHORT = 5123,
  73404. /**
  73405. * Unsigned Int
  73406. */
  73407. UNSIGNED_INT = 5125,
  73408. /**
  73409. * Float
  73410. */
  73411. FLOAT = 5126,
  73412. }
  73413. /**
  73414. * Specifies if the attirbute is a scalar, vector, or matrix
  73415. */
  73416. const enum AccessorType {
  73417. /**
  73418. * Scalar
  73419. */
  73420. SCALAR = "SCALAR",
  73421. /**
  73422. * Vector2
  73423. */
  73424. VEC2 = "VEC2",
  73425. /**
  73426. * Vector3
  73427. */
  73428. VEC3 = "VEC3",
  73429. /**
  73430. * Vector4
  73431. */
  73432. VEC4 = "VEC4",
  73433. /**
  73434. * Matrix2x2
  73435. */
  73436. MAT2 = "MAT2",
  73437. /**
  73438. * Matrix3x3
  73439. */
  73440. MAT3 = "MAT3",
  73441. /**
  73442. * Matrix4x4
  73443. */
  73444. MAT4 = "MAT4",
  73445. }
  73446. /**
  73447. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  73448. */
  73449. const enum AnimationChannelTargetPath {
  73450. /**
  73451. * Translation
  73452. */
  73453. TRANSLATION = "translation",
  73454. /**
  73455. * Rotation
  73456. */
  73457. ROTATION = "rotation",
  73458. /**
  73459. * Scale
  73460. */
  73461. SCALE = "scale",
  73462. /**
  73463. * Weights
  73464. */
  73465. WEIGHTS = "weights",
  73466. }
  73467. /**
  73468. * Interpolation algorithm
  73469. */
  73470. const enum AnimationSamplerInterpolation {
  73471. /**
  73472. * The animated values are linearly interpolated between keyframes
  73473. */
  73474. LINEAR = "LINEAR",
  73475. /**
  73476. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  73477. */
  73478. STEP = "STEP",
  73479. /**
  73480. * The animation's interpolation is computed using a cubic spline with specified tangents
  73481. */
  73482. CUBICSPLINE = "CUBICSPLINE",
  73483. }
  73484. /**
  73485. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  73486. */
  73487. const enum CameraType {
  73488. /**
  73489. * A perspective camera containing properties to create a perspective projection matrix
  73490. */
  73491. PERSPECTIVE = "perspective",
  73492. /**
  73493. * An orthographic camera containing properties to create an orthographic projection matrix
  73494. */
  73495. ORTHOGRAPHIC = "orthographic",
  73496. }
  73497. /**
  73498. * The mime-type of the image
  73499. */
  73500. const enum ImageMimeType {
  73501. /**
  73502. * JPEG Mime-type
  73503. */
  73504. JPEG = "image/jpeg",
  73505. /**
  73506. * PNG Mime-type
  73507. */
  73508. PNG = "image/png",
  73509. }
  73510. /**
  73511. * The alpha rendering mode of the material
  73512. */
  73513. const enum MaterialAlphaMode {
  73514. /**
  73515. * The alpha value is ignored and the rendered output is fully opaque
  73516. */
  73517. OPAQUE = "OPAQUE",
  73518. /**
  73519. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  73520. */
  73521. MASK = "MASK",
  73522. /**
  73523. * 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)
  73524. */
  73525. BLEND = "BLEND",
  73526. }
  73527. /**
  73528. * The type of the primitives to render
  73529. */
  73530. const enum MeshPrimitiveMode {
  73531. /**
  73532. * Points
  73533. */
  73534. POINTS = 0,
  73535. /**
  73536. * Lines
  73537. */
  73538. LINES = 1,
  73539. /**
  73540. * Line Loop
  73541. */
  73542. LINE_LOOP = 2,
  73543. /**
  73544. * Line Strip
  73545. */
  73546. LINE_STRIP = 3,
  73547. /**
  73548. * Triangles
  73549. */
  73550. TRIANGLES = 4,
  73551. /**
  73552. * Triangle Strip
  73553. */
  73554. TRIANGLE_STRIP = 5,
  73555. /**
  73556. * Triangle Fan
  73557. */
  73558. TRIANGLE_FAN = 6,
  73559. }
  73560. /**
  73561. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  73562. */
  73563. const enum TextureMagFilter {
  73564. /**
  73565. * Nearest
  73566. */
  73567. NEAREST = 9728,
  73568. /**
  73569. * Linear
  73570. */
  73571. LINEAR = 9729,
  73572. }
  73573. /**
  73574. * Minification filter. All valid values correspond to WebGL enums
  73575. */
  73576. const enum TextureMinFilter {
  73577. /**
  73578. * Nearest
  73579. */
  73580. NEAREST = 9728,
  73581. /**
  73582. * Linear
  73583. */
  73584. LINEAR = 9729,
  73585. /**
  73586. * Nearest Mip-Map Nearest
  73587. */
  73588. NEAREST_MIPMAP_NEAREST = 9984,
  73589. /**
  73590. * Linear Mipmap Nearest
  73591. */
  73592. LINEAR_MIPMAP_NEAREST = 9985,
  73593. /**
  73594. * Nearest Mipmap Linear
  73595. */
  73596. NEAREST_MIPMAP_LINEAR = 9986,
  73597. /**
  73598. * Linear Mipmap Linear
  73599. */
  73600. LINEAR_MIPMAP_LINEAR = 9987,
  73601. }
  73602. /**
  73603. * S (U) wrapping mode. All valid values correspond to WebGL enums
  73604. */
  73605. const enum TextureWrapMode {
  73606. /**
  73607. * Clamp to Edge
  73608. */
  73609. CLAMP_TO_EDGE = 33071,
  73610. /**
  73611. * Mirrored Repeat
  73612. */
  73613. MIRRORED_REPEAT = 33648,
  73614. /**
  73615. * Repeat
  73616. */
  73617. REPEAT = 10497,
  73618. }
  73619. /**
  73620. * glTF Property
  73621. */
  73622. interface IProperty {
  73623. /**
  73624. * Dictionary object with extension-specific objects
  73625. */
  73626. extensions?: {
  73627. [key: string]: any;
  73628. };
  73629. /**
  73630. * Application-Specific data
  73631. */
  73632. extras?: any;
  73633. }
  73634. /**
  73635. * glTF Child of Root Property
  73636. */
  73637. interface IChildRootProperty extends IProperty {
  73638. /**
  73639. * The user-defined name of this object
  73640. */
  73641. name?: string;
  73642. }
  73643. /**
  73644. * Indices of those attributes that deviate from their initialization value
  73645. */
  73646. interface IAccessorSparseIndices extends IProperty {
  73647. /**
  73648. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  73649. */
  73650. bufferView: number;
  73651. /**
  73652. * The offset relative to the start of the bufferView in bytes. Must be aligned
  73653. */
  73654. byteOffset?: number;
  73655. /**
  73656. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  73657. */
  73658. componentType: AccessorComponentType;
  73659. }
  73660. /**
  73661. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  73662. */
  73663. interface IAccessorSparseValues extends IProperty {
  73664. /**
  73665. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  73666. */
  73667. bufferView: number;
  73668. /**
  73669. * The offset relative to the start of the bufferView in bytes. Must be aligned
  73670. */
  73671. byteOffset?: number;
  73672. }
  73673. /**
  73674. * Sparse storage of attributes that deviate from their initialization value
  73675. */
  73676. interface IAccessorSparse extends IProperty {
  73677. /**
  73678. * The number of attributes encoded in this sparse accessor
  73679. */
  73680. count: number;
  73681. /**
  73682. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  73683. */
  73684. indices: IAccessorSparseIndices;
  73685. /**
  73686. * 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
  73687. */
  73688. values: IAccessorSparseValues;
  73689. }
  73690. /**
  73691. * 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
  73692. */
  73693. interface IAccessor extends IChildRootProperty {
  73694. /**
  73695. * The index of the bufferview
  73696. */
  73697. bufferView?: number;
  73698. /**
  73699. * The offset relative to the start of the bufferView in bytes
  73700. */
  73701. byteOffset?: number;
  73702. /**
  73703. * The datatype of components in the attribute
  73704. */
  73705. componentType: AccessorComponentType;
  73706. /**
  73707. * Specifies whether integer data values should be normalized
  73708. */
  73709. normalized?: boolean;
  73710. /**
  73711. * The number of attributes referenced by this accessor
  73712. */
  73713. count: number;
  73714. /**
  73715. * Specifies if the attribute is a scalar, vector, or matrix
  73716. */
  73717. type: AccessorType;
  73718. /**
  73719. * Maximum value of each component in this attribute
  73720. */
  73721. max?: number[];
  73722. /**
  73723. * Minimum value of each component in this attribute
  73724. */
  73725. min?: number[];
  73726. /**
  73727. * Sparse storage of attributes that deviate from their initialization value
  73728. */
  73729. sparse?: IAccessorSparse;
  73730. }
  73731. /**
  73732. * Targets an animation's sampler at a node's property
  73733. */
  73734. interface IAnimationChannel extends IProperty {
  73735. /**
  73736. * The index of a sampler in this animation used to compute the value for the target
  73737. */
  73738. sampler: number;
  73739. /**
  73740. * The index of the node and TRS property to target
  73741. */
  73742. target: IAnimationChannelTarget;
  73743. }
  73744. /**
  73745. * The index of the node and TRS property that an animation channel targets
  73746. */
  73747. interface IAnimationChannelTarget extends IProperty {
  73748. /**
  73749. * The index of the node to target
  73750. */
  73751. node: number;
  73752. /**
  73753. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  73754. */
  73755. path: AnimationChannelTargetPath;
  73756. }
  73757. /**
  73758. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  73759. */
  73760. interface IAnimationSampler extends IProperty {
  73761. /**
  73762. * The index of an accessor containing keyframe input values, e.g., time
  73763. */
  73764. input: number;
  73765. /**
  73766. * Interpolation algorithm
  73767. */
  73768. interpolation?: AnimationSamplerInterpolation;
  73769. /**
  73770. * The index of an accessor, containing keyframe output values
  73771. */
  73772. output: number;
  73773. }
  73774. /**
  73775. * A keyframe animation
  73776. */
  73777. interface IAnimation extends IChildRootProperty {
  73778. /**
  73779. * An array of channels, each of which targets an animation's sampler at a node's property
  73780. */
  73781. channels: IAnimationChannel[];
  73782. /**
  73783. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  73784. */
  73785. samplers: IAnimationSampler[];
  73786. }
  73787. /**
  73788. * Metadata about the glTF asset
  73789. */
  73790. interface IAsset extends IChildRootProperty {
  73791. /**
  73792. * A copyright message suitable for display to credit the content creator
  73793. */
  73794. copyright?: string;
  73795. /**
  73796. * Tool that generated this glTF model. Useful for debugging
  73797. */
  73798. generator?: string;
  73799. /**
  73800. * The glTF version that this asset targets
  73801. */
  73802. version: string;
  73803. /**
  73804. * The minimum glTF version that this asset targets
  73805. */
  73806. minVersion?: string;
  73807. }
  73808. /**
  73809. * A buffer points to binary geometry, animation, or skins
  73810. */
  73811. interface IBuffer extends IChildRootProperty {
  73812. /**
  73813. * 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
  73814. */
  73815. uri?: string;
  73816. /**
  73817. * The length of the buffer in bytes
  73818. */
  73819. byteLength: number;
  73820. }
  73821. /**
  73822. * A view into a buffer generally representing a subset of the buffer
  73823. */
  73824. interface IBufferView extends IChildRootProperty {
  73825. /**
  73826. * The index of the buffer
  73827. */
  73828. buffer: number;
  73829. /**
  73830. * The offset into the buffer in bytes
  73831. */
  73832. byteOffset?: number;
  73833. /**
  73834. * The lenth of the bufferView in bytes
  73835. */
  73836. byteLength: number;
  73837. /**
  73838. * The stride, in bytes
  73839. */
  73840. byteStride?: number;
  73841. }
  73842. /**
  73843. * An orthographic camera containing properties to create an orthographic projection matrix
  73844. */
  73845. interface ICameraOrthographic extends IProperty {
  73846. /**
  73847. * The floating-point horizontal magnification of the view. Must not be zero
  73848. */
  73849. xmag: number;
  73850. /**
  73851. * The floating-point vertical magnification of the view. Must not be zero
  73852. */
  73853. ymag: number;
  73854. /**
  73855. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  73856. */
  73857. zfar: number;
  73858. /**
  73859. * The floating-point distance to the near clipping plane
  73860. */
  73861. znear: number;
  73862. }
  73863. /**
  73864. * A perspective camera containing properties to create a perspective projection matrix
  73865. */
  73866. interface ICameraPerspective extends IProperty {
  73867. /**
  73868. * The floating-point aspect ratio of the field of view
  73869. */
  73870. aspectRatio?: number;
  73871. /**
  73872. * The floating-point vertical field of view in radians
  73873. */
  73874. yfov: number;
  73875. /**
  73876. * The floating-point distance to the far clipping plane
  73877. */
  73878. zfar?: number;
  73879. /**
  73880. * The floating-point distance to the near clipping plane
  73881. */
  73882. znear: number;
  73883. }
  73884. /**
  73885. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  73886. */
  73887. interface ICamera extends IChildRootProperty {
  73888. /**
  73889. * An orthographic camera containing properties to create an orthographic projection matrix
  73890. */
  73891. orthographic?: ICameraOrthographic;
  73892. /**
  73893. * A perspective camera containing properties to create a perspective projection matrix
  73894. */
  73895. perspective?: ICameraPerspective;
  73896. /**
  73897. * Specifies if the camera uses a perspective or orthographic projection
  73898. */
  73899. type: CameraType;
  73900. }
  73901. /**
  73902. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  73903. */
  73904. interface IImage extends IChildRootProperty {
  73905. /**
  73906. * 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
  73907. */
  73908. uri?: string;
  73909. /**
  73910. * The image's MIME type
  73911. */
  73912. mimeType?: ImageMimeType;
  73913. /**
  73914. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  73915. */
  73916. bufferView?: number;
  73917. }
  73918. /**
  73919. * Material Normal Texture Info
  73920. */
  73921. interface IMaterialNormalTextureInfo extends ITextureInfo {
  73922. /**
  73923. * The scalar multiplier applied to each normal vector of the normal texture
  73924. */
  73925. scale?: number;
  73926. }
  73927. /**
  73928. * Material Occlusion Texture Info
  73929. */
  73930. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  73931. /**
  73932. * A scalar multiplier controlling the amount of occlusion applied
  73933. */
  73934. strength?: number;
  73935. }
  73936. /**
  73937. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  73938. */
  73939. interface IMaterialPbrMetallicRoughness {
  73940. /**
  73941. * The material's base color factor
  73942. */
  73943. baseColorFactor?: number[];
  73944. /**
  73945. * The base color texture
  73946. */
  73947. baseColorTexture?: ITextureInfo;
  73948. /**
  73949. * The metalness of the material
  73950. */
  73951. metallicFactor?: number;
  73952. /**
  73953. * The roughness of the material
  73954. */
  73955. roughnessFactor?: number;
  73956. /**
  73957. * The metallic-roughness texture
  73958. */
  73959. metallicRoughnessTexture?: ITextureInfo;
  73960. }
  73961. /**
  73962. * The material appearance of a primitive
  73963. */
  73964. interface IMaterial extends IChildRootProperty {
  73965. /**
  73966. * 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
  73967. */
  73968. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  73969. /**
  73970. * The normal map texture
  73971. */
  73972. normalTexture?: IMaterialNormalTextureInfo;
  73973. /**
  73974. * The occlusion map texture
  73975. */
  73976. occlusionTexture?: IMaterialOcclusionTextureInfo;
  73977. /**
  73978. * The emissive map texture
  73979. */
  73980. emissiveTexture?: ITextureInfo;
  73981. /**
  73982. * 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
  73983. */
  73984. emissiveFactor?: number[];
  73985. /**
  73986. * The alpha rendering mode of the material
  73987. */
  73988. alphaMode?: MaterialAlphaMode;
  73989. /**
  73990. * The alpha cutoff value of the material
  73991. */
  73992. alphaCutoff?: number;
  73993. /**
  73994. * Specifies whether the material is double sided
  73995. */
  73996. doubleSided?: boolean;
  73997. }
  73998. /**
  73999. * Geometry to be rendered with the given material
  74000. */
  74001. interface IMeshPrimitive extends IProperty {
  74002. /**
  74003. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  74004. */
  74005. attributes: {
  74006. [name: string]: number;
  74007. };
  74008. /**
  74009. * The index of the accessor that contains the indices
  74010. */
  74011. indices?: number;
  74012. /**
  74013. * The index of the material to apply to this primitive when rendering
  74014. */
  74015. material?: number;
  74016. /**
  74017. * The type of primitives to render. All valid values correspond to WebGL enums
  74018. */
  74019. mode?: MeshPrimitiveMode;
  74020. /**
  74021. * 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
  74022. */
  74023. targets?: {
  74024. [name: string]: number;
  74025. }[];
  74026. }
  74027. /**
  74028. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  74029. */
  74030. interface IMesh extends IChildRootProperty {
  74031. /**
  74032. * An array of primitives, each defining geometry to be rendered with a material
  74033. */
  74034. primitives: IMeshPrimitive[];
  74035. /**
  74036. * Array of weights to be applied to the Morph Targets
  74037. */
  74038. weights?: number[];
  74039. }
  74040. /**
  74041. * A node in the node hierarchy
  74042. */
  74043. interface INode extends IChildRootProperty {
  74044. /**
  74045. * The index of the camera referenced by this node
  74046. */
  74047. camera?: number;
  74048. /**
  74049. * The indices of this node's children
  74050. */
  74051. children?: number[];
  74052. /**
  74053. * The index of the skin referenced by this node
  74054. */
  74055. skin?: number;
  74056. /**
  74057. * A floating-point 4x4 transformation matrix stored in column-major order
  74058. */
  74059. matrix?: number[];
  74060. /**
  74061. * The index of the mesh in this node
  74062. */
  74063. mesh?: number;
  74064. /**
  74065. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  74066. */
  74067. rotation?: number[];
  74068. /**
  74069. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  74070. */
  74071. scale?: number[];
  74072. /**
  74073. * The node's translation along the x, y, and z axes
  74074. */
  74075. translation?: number[];
  74076. /**
  74077. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  74078. */
  74079. weights?: number[];
  74080. }
  74081. /**
  74082. * Texture sampler properties for filtering and wrapping modes
  74083. */
  74084. interface ISampler extends IChildRootProperty {
  74085. /**
  74086. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  74087. */
  74088. magFilter?: TextureMagFilter;
  74089. /**
  74090. * Minification filter. All valid values correspond to WebGL enums
  74091. */
  74092. minFilter?: TextureMinFilter;
  74093. /**
  74094. * S (U) wrapping mode. All valid values correspond to WebGL enums
  74095. */
  74096. wrapS?: TextureWrapMode;
  74097. /**
  74098. * T (V) wrapping mode. All valid values correspond to WebGL enums
  74099. */
  74100. wrapT?: TextureWrapMode;
  74101. }
  74102. /**
  74103. * The root nodes of a scene
  74104. */
  74105. interface IScene extends IChildRootProperty {
  74106. /**
  74107. * The indices of each root node
  74108. */
  74109. nodes: number[];
  74110. }
  74111. /**
  74112. * Joints and matrices defining a skin
  74113. */
  74114. interface ISkin extends IChildRootProperty {
  74115. /**
  74116. * 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
  74117. */
  74118. inverseBindMatrices?: number;
  74119. /**
  74120. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  74121. */
  74122. skeleton?: number;
  74123. /**
  74124. * 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)
  74125. */
  74126. joints: number[];
  74127. }
  74128. /**
  74129. * A texture and its sampler
  74130. */
  74131. interface ITexture extends IChildRootProperty {
  74132. /**
  74133. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  74134. */
  74135. sampler?: number;
  74136. /**
  74137. * The index of the image used by this texture
  74138. */
  74139. source: number;
  74140. }
  74141. /**
  74142. * Reference to a texture
  74143. */
  74144. interface ITextureInfo extends IProperty {
  74145. /**
  74146. * The index of the texture
  74147. */
  74148. index: number;
  74149. /**
  74150. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  74151. */
  74152. texCoord?: number;
  74153. }
  74154. /**
  74155. * The root object for a glTF asset
  74156. */
  74157. interface IGLTF extends IProperty {
  74158. /**
  74159. * An array of accessors. An accessor is a typed view into a bufferView
  74160. */
  74161. accessors?: IAccessor[];
  74162. /**
  74163. * An array of keyframe animations
  74164. */
  74165. animations?: IAnimation[];
  74166. /**
  74167. * Metadata about the glTF asset
  74168. */
  74169. asset: IAsset;
  74170. /**
  74171. * An array of buffers. A buffer points to binary geometry, animation, or skins
  74172. */
  74173. buffers?: IBuffer[];
  74174. /**
  74175. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  74176. */
  74177. bufferViews?: IBufferView[];
  74178. /**
  74179. * An array of cameras
  74180. */
  74181. cameras?: ICamera[];
  74182. /**
  74183. * Names of glTF extensions used somewhere in this asset
  74184. */
  74185. extensionsUsed?: string[];
  74186. /**
  74187. * Names of glTF extensions required to properly load this asset
  74188. */
  74189. extensionsRequired?: string[];
  74190. /**
  74191. * An array of images. An image defines data used to create a texture
  74192. */
  74193. images?: IImage[];
  74194. /**
  74195. * An array of materials. A material defines the appearance of a primitive
  74196. */
  74197. materials?: IMaterial[];
  74198. /**
  74199. * An array of meshes. A mesh is a set of primitives to be rendered
  74200. */
  74201. meshes?: IMesh[];
  74202. /**
  74203. * An array of nodes
  74204. */
  74205. nodes?: INode[];
  74206. /**
  74207. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  74208. */
  74209. samplers?: ISampler[];
  74210. /**
  74211. * The index of the default scene
  74212. */
  74213. scene?: number;
  74214. /**
  74215. * An array of scenes
  74216. */
  74217. scenes?: IScene[];
  74218. /**
  74219. * An array of skins. A skin is defined by joints and matrices
  74220. */
  74221. skins?: ISkin[];
  74222. /**
  74223. * An array of textures
  74224. */
  74225. textures?: ITexture[];
  74226. }
  74227. /**
  74228. * The glTF validation results
  74229. * @ignore
  74230. */
  74231. interface IGLTFValidationResults {
  74232. info: {
  74233. generator: string;
  74234. hasAnimations: boolean;
  74235. hasDefaultScene: boolean;
  74236. hasMaterials: boolean;
  74237. hasMorphTargets: boolean;
  74238. hasSkins: boolean;
  74239. hasTextures: boolean;
  74240. maxAttributesUsed: number;
  74241. primitivesCount: number
  74242. };
  74243. issues: {
  74244. messages: Array<string>;
  74245. numErrors: number;
  74246. numHints: number;
  74247. numInfos: number;
  74248. numWarnings: number;
  74249. truncated: boolean
  74250. };
  74251. mimeType: string;
  74252. uri: string;
  74253. validatedAt: string;
  74254. validatorVersion: string;
  74255. }
  74256. /**
  74257. * The glTF validation options
  74258. */
  74259. interface IGLTFValidationOptions {
  74260. /** Uri to use */
  74261. uri?: string;
  74262. /** Function used to load external resources */
  74263. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  74264. /** Boolean indicating that we need to validate accessor data */
  74265. validateAccessorData?: boolean;
  74266. /** max number of issues allowed */
  74267. maxIssues?: number;
  74268. /** Ignored issues */
  74269. ignoredIssues?: Array<string>;
  74270. /** Value to override severy settings */
  74271. severityOverrides?: Object;
  74272. }
  74273. /**
  74274. * The glTF validator object
  74275. * @ignore
  74276. */
  74277. interface IGLTFValidator {
  74278. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  74279. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  74280. }
  74281. }
  74282. declare module BABYLON {
  74283. /** @hidden */
  74284. export var cellPixelShader: {
  74285. name: string;
  74286. shader: string;
  74287. };
  74288. }
  74289. declare module BABYLON {
  74290. /** @hidden */
  74291. export var cellVertexShader: {
  74292. name: string;
  74293. shader: string;
  74294. };
  74295. }
  74296. declare module BABYLON {
  74297. export class CellMaterial extends BABYLON.PushMaterial {
  74298. private _diffuseTexture;
  74299. diffuseTexture: BABYLON.BaseTexture;
  74300. diffuseColor: BABYLON.Color3;
  74301. _computeHighLevel: boolean;
  74302. computeHighLevel: boolean;
  74303. private _disableLighting;
  74304. disableLighting: boolean;
  74305. private _maxSimultaneousLights;
  74306. maxSimultaneousLights: number;
  74307. private _renderId;
  74308. constructor(name: string, scene: BABYLON.Scene);
  74309. needAlphaBlending(): boolean;
  74310. needAlphaTesting(): boolean;
  74311. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74312. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74313. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74314. getAnimatables(): BABYLON.IAnimatable[];
  74315. getActiveTextures(): BABYLON.BaseTexture[];
  74316. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74317. dispose(forceDisposeEffect?: boolean): void;
  74318. getClassName(): string;
  74319. clone(name: string): CellMaterial;
  74320. serialize(): any;
  74321. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  74322. }
  74323. }
  74324. declare module BABYLON {
  74325. export class CustomShaderStructure {
  74326. FragmentStore: string;
  74327. VertexStore: string;
  74328. constructor();
  74329. }
  74330. export class ShaderSpecialParts {
  74331. constructor();
  74332. Fragment_Begin: string;
  74333. Fragment_Definitions: string;
  74334. Fragment_MainBegin: string;
  74335. Fragment_Custom_Diffuse: string;
  74336. Fragment_Before_Lights: string;
  74337. Fragment_Before_Fog: string;
  74338. Fragment_Custom_Alpha: string;
  74339. Fragment_Before_FragColor: string;
  74340. Vertex_Begin: string;
  74341. Vertex_Definitions: string;
  74342. Vertex_MainBegin: string;
  74343. Vertex_Before_PositionUpdated: string;
  74344. Vertex_Before_NormalUpdated: string;
  74345. Vertex_MainEnd: string;
  74346. }
  74347. export class CustomMaterial extends BABYLON.StandardMaterial {
  74348. static ShaderIndexer: number;
  74349. CustomParts: ShaderSpecialParts;
  74350. _isCreatedShader: boolean;
  74351. _createdShaderName: string;
  74352. _customUniform: string[];
  74353. _newUniforms: string[];
  74354. _newUniformInstances: any[];
  74355. _newSamplerInstances: BABYLON.Texture[];
  74356. FragmentShader: string;
  74357. VertexShader: string;
  74358. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  74359. ReviewUniform(name: string, arr: string[]): string[];
  74360. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  74361. constructor(name: string, scene: BABYLON.Scene);
  74362. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  74363. Fragment_Begin(shaderPart: string): CustomMaterial;
  74364. Fragment_Definitions(shaderPart: string): CustomMaterial;
  74365. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  74366. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  74367. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  74368. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  74369. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  74370. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  74371. Vertex_Begin(shaderPart: string): CustomMaterial;
  74372. Vertex_Definitions(shaderPart: string): CustomMaterial;
  74373. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  74374. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  74375. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  74376. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  74377. }
  74378. }
  74379. declare module BABYLON {
  74380. export class ShaderAlebdoParts {
  74381. constructor();
  74382. Fragment_Begin: string;
  74383. Fragment_Definitions: string;
  74384. Fragment_MainBegin: string;
  74385. Fragment_Custom_Albedo: string;
  74386. Fragment_Before_Lights: string;
  74387. Fragment_Custom_MetallicRoughness: string;
  74388. Fragment_Custom_MicroSurface: string;
  74389. Fragment_Before_Fog: string;
  74390. Fragment_Custom_Alpha: string;
  74391. Fragment_Before_FragColor: string;
  74392. Vertex_Begin: string;
  74393. Vertex_Definitions: string;
  74394. Vertex_MainBegin: string;
  74395. Vertex_Before_PositionUpdated: string;
  74396. Vertex_Before_NormalUpdated: string;
  74397. Vertex_MainEnd: string;
  74398. }
  74399. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  74400. static ShaderIndexer: number;
  74401. CustomParts: ShaderAlebdoParts;
  74402. _isCreatedShader: boolean;
  74403. _createdShaderName: string;
  74404. _customUniform: string[];
  74405. _newUniforms: string[];
  74406. _newUniformInstances: any[];
  74407. _newSamplerInstances: BABYLON.Texture[];
  74408. FragmentShader: string;
  74409. VertexShader: string;
  74410. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  74411. ReviewUniform(name: string, arr: string[]): string[];
  74412. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  74413. constructor(name: string, scene: BABYLON.Scene);
  74414. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  74415. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  74416. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  74417. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  74418. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  74419. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  74420. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  74421. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  74422. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  74423. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  74424. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  74425. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  74426. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  74427. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  74428. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  74429. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  74430. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  74431. }
  74432. }
  74433. declare module BABYLON {
  74434. /** @hidden */
  74435. export var firePixelShader: {
  74436. name: string;
  74437. shader: string;
  74438. };
  74439. }
  74440. declare module BABYLON {
  74441. /** @hidden */
  74442. export var fireVertexShader: {
  74443. name: string;
  74444. shader: string;
  74445. };
  74446. }
  74447. declare module BABYLON {
  74448. export class FireMaterial extends BABYLON.PushMaterial {
  74449. private _diffuseTexture;
  74450. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  74451. private _distortionTexture;
  74452. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  74453. private _opacityTexture;
  74454. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  74455. diffuseColor: BABYLON.Color3;
  74456. speed: number;
  74457. private _scaledDiffuse;
  74458. private _renderId;
  74459. private _lastTime;
  74460. constructor(name: string, scene: BABYLON.Scene);
  74461. needAlphaBlending(): boolean;
  74462. needAlphaTesting(): boolean;
  74463. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74464. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74465. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74466. getAnimatables(): BABYLON.IAnimatable[];
  74467. getActiveTextures(): BABYLON.BaseTexture[];
  74468. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74469. getClassName(): string;
  74470. dispose(forceDisposeEffect?: boolean): void;
  74471. clone(name: string): FireMaterial;
  74472. serialize(): any;
  74473. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  74474. }
  74475. }
  74476. declare module BABYLON {
  74477. /** @hidden */
  74478. export var furPixelShader: {
  74479. name: string;
  74480. shader: string;
  74481. };
  74482. }
  74483. declare module BABYLON {
  74484. /** @hidden */
  74485. export var furVertexShader: {
  74486. name: string;
  74487. shader: string;
  74488. };
  74489. }
  74490. declare module BABYLON {
  74491. export class FurMaterial extends BABYLON.PushMaterial {
  74492. private _diffuseTexture;
  74493. diffuseTexture: BABYLON.BaseTexture;
  74494. private _heightTexture;
  74495. heightTexture: BABYLON.BaseTexture;
  74496. diffuseColor: BABYLON.Color3;
  74497. furLength: number;
  74498. furAngle: number;
  74499. furColor: BABYLON.Color3;
  74500. furOffset: number;
  74501. furSpacing: number;
  74502. furGravity: BABYLON.Vector3;
  74503. furSpeed: number;
  74504. furDensity: number;
  74505. furOcclusion: number;
  74506. furTexture: BABYLON.DynamicTexture;
  74507. private _disableLighting;
  74508. disableLighting: boolean;
  74509. private _maxSimultaneousLights;
  74510. maxSimultaneousLights: number;
  74511. highLevelFur: boolean;
  74512. _meshes: BABYLON.AbstractMesh[];
  74513. private _renderId;
  74514. private _furTime;
  74515. constructor(name: string, scene: BABYLON.Scene);
  74516. furTime: number;
  74517. needAlphaBlending(): boolean;
  74518. needAlphaTesting(): boolean;
  74519. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74520. updateFur(): void;
  74521. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74522. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74523. getAnimatables(): BABYLON.IAnimatable[];
  74524. getActiveTextures(): BABYLON.BaseTexture[];
  74525. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74526. dispose(forceDisposeEffect?: boolean): void;
  74527. clone(name: string): FurMaterial;
  74528. serialize(): any;
  74529. getClassName(): string;
  74530. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  74531. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  74532. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  74533. }
  74534. }
  74535. declare module BABYLON {
  74536. /** @hidden */
  74537. export var gradientPixelShader: {
  74538. name: string;
  74539. shader: string;
  74540. };
  74541. }
  74542. declare module BABYLON {
  74543. /** @hidden */
  74544. export var gradientVertexShader: {
  74545. name: string;
  74546. shader: string;
  74547. };
  74548. }
  74549. declare module BABYLON {
  74550. export class GradientMaterial extends BABYLON.PushMaterial {
  74551. private _maxSimultaneousLights;
  74552. maxSimultaneousLights: number;
  74553. topColor: BABYLON.Color3;
  74554. topColorAlpha: number;
  74555. bottomColor: BABYLON.Color3;
  74556. bottomColorAlpha: number;
  74557. offset: number;
  74558. scale: number;
  74559. smoothness: number;
  74560. private _disableLighting;
  74561. disableLighting: boolean;
  74562. private _renderId;
  74563. constructor(name: string, scene: BABYLON.Scene);
  74564. needAlphaBlending(): boolean;
  74565. needAlphaTesting(): boolean;
  74566. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74567. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74568. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74569. getAnimatables(): BABYLON.IAnimatable[];
  74570. dispose(forceDisposeEffect?: boolean): void;
  74571. clone(name: string): GradientMaterial;
  74572. serialize(): any;
  74573. getClassName(): string;
  74574. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  74575. }
  74576. }
  74577. declare module BABYLON {
  74578. /** @hidden */
  74579. export var gridPixelShader: {
  74580. name: string;
  74581. shader: string;
  74582. };
  74583. }
  74584. declare module BABYLON {
  74585. /** @hidden */
  74586. export var gridVertexShader: {
  74587. name: string;
  74588. shader: string;
  74589. };
  74590. }
  74591. declare module BABYLON {
  74592. /**
  74593. * The grid materials allows you to wrap any shape with a grid.
  74594. * Colors are customizable.
  74595. */
  74596. export class GridMaterial extends BABYLON.PushMaterial {
  74597. /**
  74598. * Main color of the grid (e.g. between lines)
  74599. */
  74600. mainColor: BABYLON.Color3;
  74601. /**
  74602. * Color of the grid lines.
  74603. */
  74604. lineColor: BABYLON.Color3;
  74605. /**
  74606. * The scale of the grid compared to unit.
  74607. */
  74608. gridRatio: number;
  74609. /**
  74610. * Allows setting an offset for the grid lines.
  74611. */
  74612. gridOffset: BABYLON.Vector3;
  74613. /**
  74614. * The frequency of thicker lines.
  74615. */
  74616. majorUnitFrequency: number;
  74617. /**
  74618. * The visibility of minor units in the grid.
  74619. */
  74620. minorUnitVisibility: number;
  74621. /**
  74622. * The grid opacity outside of the lines.
  74623. */
  74624. opacity: number;
  74625. /**
  74626. * Determine RBG output is premultiplied by alpha value.
  74627. */
  74628. preMultiplyAlpha: boolean;
  74629. private _opacityTexture;
  74630. opacityTexture: BABYLON.BaseTexture;
  74631. private _gridControl;
  74632. private _renderId;
  74633. /**
  74634. * constructor
  74635. * @param name The name given to the material in order to identify it afterwards.
  74636. * @param scene The scene the material is used in.
  74637. */
  74638. constructor(name: string, scene: BABYLON.Scene);
  74639. /**
  74640. * Returns wehter or not the grid requires alpha blending.
  74641. */
  74642. needAlphaBlending(): boolean;
  74643. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  74644. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74645. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74646. /**
  74647. * Dispose the material and its associated resources.
  74648. * @param forceDisposeEffect will also dispose the used effect when true
  74649. */
  74650. dispose(forceDisposeEffect?: boolean): void;
  74651. clone(name: string): GridMaterial;
  74652. serialize(): any;
  74653. getClassName(): string;
  74654. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  74655. }
  74656. }
  74657. declare module BABYLON {
  74658. /** @hidden */
  74659. export var lavaPixelShader: {
  74660. name: string;
  74661. shader: string;
  74662. };
  74663. }
  74664. declare module BABYLON {
  74665. /** @hidden */
  74666. export var lavaVertexShader: {
  74667. name: string;
  74668. shader: string;
  74669. };
  74670. }
  74671. declare module BABYLON {
  74672. export class LavaMaterial extends BABYLON.PushMaterial {
  74673. private _diffuseTexture;
  74674. diffuseTexture: BABYLON.BaseTexture;
  74675. noiseTexture: BABYLON.BaseTexture;
  74676. fogColor: BABYLON.Color3;
  74677. speed: number;
  74678. movingSpeed: number;
  74679. lowFrequencySpeed: number;
  74680. fogDensity: number;
  74681. private _lastTime;
  74682. diffuseColor: BABYLON.Color3;
  74683. private _disableLighting;
  74684. disableLighting: boolean;
  74685. private _unlit;
  74686. unlit: boolean;
  74687. private _maxSimultaneousLights;
  74688. maxSimultaneousLights: number;
  74689. private _scaledDiffuse;
  74690. private _renderId;
  74691. constructor(name: string, scene: BABYLON.Scene);
  74692. needAlphaBlending(): boolean;
  74693. needAlphaTesting(): boolean;
  74694. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74695. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74696. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74697. getAnimatables(): BABYLON.IAnimatable[];
  74698. getActiveTextures(): BABYLON.BaseTexture[];
  74699. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74700. dispose(forceDisposeEffect?: boolean): void;
  74701. clone(name: string): LavaMaterial;
  74702. serialize(): any;
  74703. getClassName(): string;
  74704. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  74705. }
  74706. }
  74707. declare module BABYLON {
  74708. /** @hidden */
  74709. export var mixPixelShader: {
  74710. name: string;
  74711. shader: string;
  74712. };
  74713. }
  74714. declare module BABYLON {
  74715. /** @hidden */
  74716. export var mixVertexShader: {
  74717. name: string;
  74718. shader: string;
  74719. };
  74720. }
  74721. declare module BABYLON {
  74722. export class MixMaterial extends BABYLON.PushMaterial {
  74723. /**
  74724. * Mix textures
  74725. */
  74726. private _mixTexture1;
  74727. mixTexture1: BABYLON.BaseTexture;
  74728. private _mixTexture2;
  74729. mixTexture2: BABYLON.BaseTexture;
  74730. /**
  74731. * Diffuse textures
  74732. */
  74733. private _diffuseTexture1;
  74734. diffuseTexture1: BABYLON.Texture;
  74735. private _diffuseTexture2;
  74736. diffuseTexture2: BABYLON.Texture;
  74737. private _diffuseTexture3;
  74738. diffuseTexture3: BABYLON.Texture;
  74739. private _diffuseTexture4;
  74740. diffuseTexture4: BABYLON.Texture;
  74741. private _diffuseTexture5;
  74742. diffuseTexture5: BABYLON.Texture;
  74743. private _diffuseTexture6;
  74744. diffuseTexture6: BABYLON.Texture;
  74745. private _diffuseTexture7;
  74746. diffuseTexture7: BABYLON.Texture;
  74747. private _diffuseTexture8;
  74748. diffuseTexture8: BABYLON.Texture;
  74749. /**
  74750. * Uniforms
  74751. */
  74752. diffuseColor: BABYLON.Color3;
  74753. specularColor: BABYLON.Color3;
  74754. specularPower: number;
  74755. private _disableLighting;
  74756. disableLighting: boolean;
  74757. private _maxSimultaneousLights;
  74758. maxSimultaneousLights: number;
  74759. private _renderId;
  74760. constructor(name: string, scene: BABYLON.Scene);
  74761. needAlphaBlending(): boolean;
  74762. needAlphaTesting(): boolean;
  74763. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74764. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74765. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74766. getAnimatables(): BABYLON.IAnimatable[];
  74767. getActiveTextures(): BABYLON.BaseTexture[];
  74768. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74769. dispose(forceDisposeEffect?: boolean): void;
  74770. clone(name: string): MixMaterial;
  74771. serialize(): any;
  74772. getClassName(): string;
  74773. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  74774. }
  74775. }
  74776. declare module BABYLON {
  74777. /** @hidden */
  74778. export var normalPixelShader: {
  74779. name: string;
  74780. shader: string;
  74781. };
  74782. }
  74783. declare module BABYLON {
  74784. /** @hidden */
  74785. export var normalVertexShader: {
  74786. name: string;
  74787. shader: string;
  74788. };
  74789. }
  74790. declare module BABYLON {
  74791. export class NormalMaterial extends BABYLON.PushMaterial {
  74792. private _diffuseTexture;
  74793. diffuseTexture: BABYLON.BaseTexture;
  74794. diffuseColor: BABYLON.Color3;
  74795. private _disableLighting;
  74796. disableLighting: boolean;
  74797. private _maxSimultaneousLights;
  74798. maxSimultaneousLights: number;
  74799. private _renderId;
  74800. constructor(name: string, scene: BABYLON.Scene);
  74801. needAlphaBlending(): boolean;
  74802. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  74803. needAlphaTesting(): boolean;
  74804. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74805. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74806. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74807. getAnimatables(): BABYLON.IAnimatable[];
  74808. getActiveTextures(): BABYLON.BaseTexture[];
  74809. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74810. dispose(forceDisposeEffect?: boolean): void;
  74811. clone(name: string): NormalMaterial;
  74812. serialize(): any;
  74813. getClassName(): string;
  74814. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  74815. }
  74816. }
  74817. declare module BABYLON {
  74818. /** @hidden */
  74819. export var shadowOnlyPixelShader: {
  74820. name: string;
  74821. shader: string;
  74822. };
  74823. }
  74824. declare module BABYLON {
  74825. /** @hidden */
  74826. export var shadowOnlyVertexShader: {
  74827. name: string;
  74828. shader: string;
  74829. };
  74830. }
  74831. declare module BABYLON {
  74832. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  74833. private _renderId;
  74834. private _activeLight;
  74835. constructor(name: string, scene: BABYLON.Scene);
  74836. shadowColor: BABYLON.Color3;
  74837. needAlphaBlending(): boolean;
  74838. needAlphaTesting(): boolean;
  74839. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74840. activeLight: BABYLON.IShadowLight;
  74841. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74842. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74843. clone(name: string): ShadowOnlyMaterial;
  74844. serialize(): any;
  74845. getClassName(): string;
  74846. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  74847. }
  74848. }
  74849. declare module BABYLON {
  74850. /** @hidden */
  74851. export var simplePixelShader: {
  74852. name: string;
  74853. shader: string;
  74854. };
  74855. }
  74856. declare module BABYLON {
  74857. /** @hidden */
  74858. export var simpleVertexShader: {
  74859. name: string;
  74860. shader: string;
  74861. };
  74862. }
  74863. declare module BABYLON {
  74864. export class SimpleMaterial extends BABYLON.PushMaterial {
  74865. private _diffuseTexture;
  74866. diffuseTexture: BABYLON.BaseTexture;
  74867. diffuseColor: BABYLON.Color3;
  74868. private _disableLighting;
  74869. disableLighting: boolean;
  74870. private _maxSimultaneousLights;
  74871. maxSimultaneousLights: number;
  74872. private _renderId;
  74873. constructor(name: string, scene: BABYLON.Scene);
  74874. needAlphaBlending(): boolean;
  74875. needAlphaTesting(): boolean;
  74876. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74877. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74878. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74879. getAnimatables(): BABYLON.IAnimatable[];
  74880. getActiveTextures(): BABYLON.BaseTexture[];
  74881. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74882. dispose(forceDisposeEffect?: boolean): void;
  74883. clone(name: string): SimpleMaterial;
  74884. serialize(): any;
  74885. getClassName(): string;
  74886. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  74887. }
  74888. }
  74889. declare module BABYLON {
  74890. /** @hidden */
  74891. export var skyPixelShader: {
  74892. name: string;
  74893. shader: string;
  74894. };
  74895. }
  74896. declare module BABYLON {
  74897. /** @hidden */
  74898. export var skyVertexShader: {
  74899. name: string;
  74900. shader: string;
  74901. };
  74902. }
  74903. declare module BABYLON {
  74904. /**
  74905. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  74906. * @see https://doc.babylonjs.com/extensions/sky
  74907. */
  74908. export class SkyMaterial extends BABYLON.PushMaterial {
  74909. /**
  74910. * Defines the overall luminance of sky in interval ]0, 1[.
  74911. */
  74912. luminance: number;
  74913. /**
  74914. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  74915. */
  74916. turbidity: number;
  74917. /**
  74918. * Defines the sky appearance (light intensity).
  74919. */
  74920. rayleigh: number;
  74921. /**
  74922. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  74923. */
  74924. mieCoefficient: number;
  74925. /**
  74926. * Defines the amount of haze particles following the Mie scattering theory.
  74927. */
  74928. mieDirectionalG: number;
  74929. /**
  74930. * Defines the distance of the sun according to the active scene camera.
  74931. */
  74932. distance: number;
  74933. /**
  74934. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  74935. * "inclined".
  74936. */
  74937. inclination: number;
  74938. /**
  74939. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  74940. * an object direction and a reference direction.
  74941. */
  74942. azimuth: number;
  74943. /**
  74944. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  74945. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  74946. */
  74947. sunPosition: BABYLON.Vector3;
  74948. /**
  74949. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  74950. * .sunPosition property.
  74951. */
  74952. useSunPosition: boolean;
  74953. /**
  74954. * Defines an offset vector used to get a horizon offset.
  74955. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  74956. */
  74957. cameraOffset: BABYLON.Vector3;
  74958. private _cameraPosition;
  74959. private _renderId;
  74960. /**
  74961. * Instantiates a new sky material.
  74962. * This material allows to create dynamic and texture free
  74963. * effects for skyboxes by taking care of the atmosphere state.
  74964. * @see https://doc.babylonjs.com/extensions/sky
  74965. * @param name Define the name of the material in the scene
  74966. * @param scene Define the scene the material belong to
  74967. */
  74968. constructor(name: string, scene: BABYLON.Scene);
  74969. /**
  74970. * Specifies if the material will require alpha blending
  74971. * @returns a boolean specifying if alpha blending is needed
  74972. */
  74973. needAlphaBlending(): boolean;
  74974. /**
  74975. * Specifies if this material should be rendered in alpha test mode
  74976. * @returns false as the sky material doesn't need alpha testing.
  74977. */
  74978. needAlphaTesting(): boolean;
  74979. /**
  74980. * Get the texture used for alpha test purpose.
  74981. * @returns null as the sky material has no texture.
  74982. */
  74983. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74984. /**
  74985. * Get if the submesh is ready to be used and all its information available.
  74986. * Child classes can use it to update shaders
  74987. * @param mesh defines the mesh to check
  74988. * @param subMesh defines which submesh to check
  74989. * @param useInstances specifies that instances should be used
  74990. * @returns a boolean indicating that the submesh is ready or not
  74991. */
  74992. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74993. /**
  74994. * Binds the submesh to this material by preparing the effect and shader to draw
  74995. * @param world defines the world transformation matrix
  74996. * @param mesh defines the mesh containing the submesh
  74997. * @param subMesh defines the submesh to bind the material to
  74998. */
  74999. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75000. /**
  75001. * Get the list of animatables in the material.
  75002. * @returns the list of animatables object used in the material
  75003. */
  75004. getAnimatables(): BABYLON.IAnimatable[];
  75005. /**
  75006. * Disposes the material
  75007. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75008. */
  75009. dispose(forceDisposeEffect?: boolean): void;
  75010. /**
  75011. * Makes a duplicate of the material, and gives it a new name
  75012. * @param name defines the new name for the duplicated material
  75013. * @returns the cloned material
  75014. */
  75015. clone(name: string): SkyMaterial;
  75016. /**
  75017. * Serializes this material in a JSON representation
  75018. * @returns the serialized material object
  75019. */
  75020. serialize(): any;
  75021. /**
  75022. * Gets the current class name of the material e.g. "SkyMaterial"
  75023. * Mainly use in serialization.
  75024. * @returns the class name
  75025. */
  75026. getClassName(): string;
  75027. /**
  75028. * Creates a sky material from parsed material data
  75029. * @param source defines the JSON representation of the material
  75030. * @param scene defines the hosting scene
  75031. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75032. * @returns a new sky material
  75033. */
  75034. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  75035. }
  75036. }
  75037. declare module BABYLON {
  75038. /** @hidden */
  75039. export var terrainPixelShader: {
  75040. name: string;
  75041. shader: string;
  75042. };
  75043. }
  75044. declare module BABYLON {
  75045. /** @hidden */
  75046. export var terrainVertexShader: {
  75047. name: string;
  75048. shader: string;
  75049. };
  75050. }
  75051. declare module BABYLON {
  75052. export class TerrainMaterial extends BABYLON.PushMaterial {
  75053. private _mixTexture;
  75054. mixTexture: BABYLON.BaseTexture;
  75055. private _diffuseTexture1;
  75056. diffuseTexture1: BABYLON.Texture;
  75057. private _diffuseTexture2;
  75058. diffuseTexture2: BABYLON.Texture;
  75059. private _diffuseTexture3;
  75060. diffuseTexture3: BABYLON.Texture;
  75061. private _bumpTexture1;
  75062. bumpTexture1: BABYLON.Texture;
  75063. private _bumpTexture2;
  75064. bumpTexture2: BABYLON.Texture;
  75065. private _bumpTexture3;
  75066. bumpTexture3: BABYLON.Texture;
  75067. diffuseColor: BABYLON.Color3;
  75068. specularColor: BABYLON.Color3;
  75069. specularPower: number;
  75070. private _disableLighting;
  75071. disableLighting: boolean;
  75072. private _maxSimultaneousLights;
  75073. maxSimultaneousLights: number;
  75074. private _renderId;
  75075. constructor(name: string, scene: BABYLON.Scene);
  75076. needAlphaBlending(): boolean;
  75077. needAlphaTesting(): boolean;
  75078. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75079. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75080. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75081. getAnimatables(): BABYLON.IAnimatable[];
  75082. getActiveTextures(): BABYLON.BaseTexture[];
  75083. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75084. dispose(forceDisposeEffect?: boolean): void;
  75085. clone(name: string): TerrainMaterial;
  75086. serialize(): any;
  75087. getClassName(): string;
  75088. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  75089. }
  75090. }
  75091. declare module BABYLON {
  75092. /** @hidden */
  75093. export var triplanarPixelShader: {
  75094. name: string;
  75095. shader: string;
  75096. };
  75097. }
  75098. declare module BABYLON {
  75099. /** @hidden */
  75100. export var triplanarVertexShader: {
  75101. name: string;
  75102. shader: string;
  75103. };
  75104. }
  75105. declare module BABYLON {
  75106. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  75107. mixTexture: BABYLON.BaseTexture;
  75108. private _diffuseTextureX;
  75109. diffuseTextureX: BABYLON.BaseTexture;
  75110. private _diffuseTextureY;
  75111. diffuseTextureY: BABYLON.BaseTexture;
  75112. private _diffuseTextureZ;
  75113. diffuseTextureZ: BABYLON.BaseTexture;
  75114. private _normalTextureX;
  75115. normalTextureX: BABYLON.BaseTexture;
  75116. private _normalTextureY;
  75117. normalTextureY: BABYLON.BaseTexture;
  75118. private _normalTextureZ;
  75119. normalTextureZ: BABYLON.BaseTexture;
  75120. tileSize: number;
  75121. diffuseColor: BABYLON.Color3;
  75122. specularColor: BABYLON.Color3;
  75123. specularPower: number;
  75124. private _disableLighting;
  75125. disableLighting: boolean;
  75126. private _maxSimultaneousLights;
  75127. maxSimultaneousLights: number;
  75128. private _renderId;
  75129. constructor(name: string, scene: BABYLON.Scene);
  75130. needAlphaBlending(): boolean;
  75131. needAlphaTesting(): boolean;
  75132. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75133. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75134. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75135. getAnimatables(): BABYLON.IAnimatable[];
  75136. getActiveTextures(): BABYLON.BaseTexture[];
  75137. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75138. dispose(forceDisposeEffect?: boolean): void;
  75139. clone(name: string): TriPlanarMaterial;
  75140. serialize(): any;
  75141. getClassName(): string;
  75142. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  75143. }
  75144. }
  75145. declare module BABYLON {
  75146. /** @hidden */
  75147. export var waterPixelShader: {
  75148. name: string;
  75149. shader: string;
  75150. };
  75151. }
  75152. declare module BABYLON {
  75153. /** @hidden */
  75154. export var waterVertexShader: {
  75155. name: string;
  75156. shader: string;
  75157. };
  75158. }
  75159. declare module BABYLON {
  75160. export class WaterMaterial extends BABYLON.PushMaterial {
  75161. renderTargetSize: BABYLON.Vector2;
  75162. private _bumpTexture;
  75163. bumpTexture: BABYLON.BaseTexture;
  75164. diffuseColor: BABYLON.Color3;
  75165. specularColor: BABYLON.Color3;
  75166. specularPower: number;
  75167. private _disableLighting;
  75168. disableLighting: boolean;
  75169. private _maxSimultaneousLights;
  75170. maxSimultaneousLights: number;
  75171. /**
  75172. * @param {number}: Represents the wind force
  75173. */
  75174. windForce: number;
  75175. /**
  75176. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  75177. */
  75178. windDirection: BABYLON.Vector2;
  75179. /**
  75180. * @param {number}: Wave height, represents the height of the waves
  75181. */
  75182. waveHeight: number;
  75183. /**
  75184. * @param {number}: Bump height, represents the bump height related to the bump map
  75185. */
  75186. bumpHeight: number;
  75187. /**
  75188. * @param {boolean}: Add a smaller moving bump to less steady waves.
  75189. */
  75190. private _bumpSuperimpose;
  75191. bumpSuperimpose: boolean;
  75192. /**
  75193. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  75194. */
  75195. private _fresnelSeparate;
  75196. fresnelSeparate: boolean;
  75197. /**
  75198. * @param {boolean}: bump Waves modify the reflection.
  75199. */
  75200. private _bumpAffectsReflection;
  75201. bumpAffectsReflection: boolean;
  75202. /**
  75203. * @param {number}: The water color blended with the refraction (near)
  75204. */
  75205. waterColor: BABYLON.Color3;
  75206. /**
  75207. * @param {number}: The blend factor related to the water color
  75208. */
  75209. colorBlendFactor: number;
  75210. /**
  75211. * @param {number}: The water color blended with the reflection (far)
  75212. */
  75213. waterColor2: BABYLON.Color3;
  75214. /**
  75215. * @param {number}: The blend factor related to the water color (reflection, far)
  75216. */
  75217. colorBlendFactor2: number;
  75218. /**
  75219. * @param {number}: Represents the maximum length of a wave
  75220. */
  75221. waveLength: number;
  75222. /**
  75223. * @param {number}: Defines the waves speed
  75224. */
  75225. waveSpeed: number;
  75226. /**
  75227. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  75228. * will avoid calculating useless pixels in the pixel shader of the water material.
  75229. */
  75230. disableClipPlane: boolean;
  75231. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  75232. private _mesh;
  75233. private _refractionRTT;
  75234. private _reflectionRTT;
  75235. private _reflectionTransform;
  75236. private _lastTime;
  75237. private _lastDeltaTime;
  75238. private _renderId;
  75239. private _useLogarithmicDepth;
  75240. private _waitingRenderList;
  75241. private _imageProcessingConfiguration;
  75242. private _imageProcessingObserver;
  75243. /**
  75244. * Gets a boolean indicating that current material needs to register RTT
  75245. */
  75246. readonly hasRenderTargetTextures: boolean;
  75247. /**
  75248. * Constructor
  75249. */
  75250. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  75251. useLogarithmicDepth: boolean;
  75252. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  75253. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  75254. addToRenderList(node: any): void;
  75255. enableRenderTargets(enable: boolean): void;
  75256. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  75257. readonly renderTargetsEnabled: boolean;
  75258. needAlphaBlending(): boolean;
  75259. needAlphaTesting(): boolean;
  75260. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75261. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75262. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75263. private _createRenderTargets;
  75264. getAnimatables(): BABYLON.IAnimatable[];
  75265. getActiveTextures(): BABYLON.BaseTexture[];
  75266. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75267. dispose(forceDisposeEffect?: boolean): void;
  75268. clone(name: string): WaterMaterial;
  75269. serialize(): any;
  75270. getClassName(): string;
  75271. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  75272. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  75273. }
  75274. }
  75275. declare module BABYLON {
  75276. /** @hidden */
  75277. export var asciiartPixelShader: {
  75278. name: string;
  75279. shader: string;
  75280. };
  75281. }
  75282. declare module BABYLON {
  75283. /**
  75284. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  75285. *
  75286. * It basically takes care rendering the font front the given font size to a texture.
  75287. * This is used later on in the postprocess.
  75288. */
  75289. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  75290. private _font;
  75291. private _text;
  75292. private _charSize;
  75293. /**
  75294. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  75295. */
  75296. readonly charSize: number;
  75297. /**
  75298. * Create a new instance of the Ascii Art FontTexture class
  75299. * @param name the name of the texture
  75300. * @param font the font to use, use the W3C CSS notation
  75301. * @param text the caracter set to use in the rendering.
  75302. * @param scene the scene that owns the texture
  75303. */
  75304. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  75305. /**
  75306. * Gets the max char width of a font.
  75307. * @param font the font to use, use the W3C CSS notation
  75308. * @return the max char width
  75309. */
  75310. private getFontWidth;
  75311. /**
  75312. * Gets the max char height of a font.
  75313. * @param font the font to use, use the W3C CSS notation
  75314. * @return the max char height
  75315. */
  75316. private getFontHeight;
  75317. /**
  75318. * Clones the current AsciiArtTexture.
  75319. * @return the clone of the texture.
  75320. */
  75321. clone(): AsciiArtFontTexture;
  75322. /**
  75323. * Parses a json object representing the texture and returns an instance of it.
  75324. * @param source the source JSON representation
  75325. * @param scene the scene to create the texture for
  75326. * @return the parsed texture
  75327. */
  75328. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  75329. }
  75330. /**
  75331. * Option available in the Ascii Art Post Process.
  75332. */
  75333. export interface IAsciiArtPostProcessOptions {
  75334. /**
  75335. * The font to use following the w3c font definition.
  75336. */
  75337. font?: string;
  75338. /**
  75339. * The character set to use in the postprocess.
  75340. */
  75341. characterSet?: string;
  75342. /**
  75343. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  75344. * This number is defined between 0 and 1;
  75345. */
  75346. mixToTile?: number;
  75347. /**
  75348. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  75349. * This number is defined between 0 and 1;
  75350. */
  75351. mixToNormal?: number;
  75352. }
  75353. /**
  75354. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  75355. *
  75356. * Simmply add it to your scene and let the nerd that lives in you have fun.
  75357. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  75358. */
  75359. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  75360. /**
  75361. * The font texture used to render the char in the post process.
  75362. */
  75363. private _asciiArtFontTexture;
  75364. /**
  75365. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  75366. * This number is defined between 0 and 1;
  75367. */
  75368. mixToTile: number;
  75369. /**
  75370. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  75371. * This number is defined between 0 and 1;
  75372. */
  75373. mixToNormal: number;
  75374. /**
  75375. * Instantiates a new Ascii Art Post Process.
  75376. * @param name the name to give to the postprocess
  75377. * @camera the camera to apply the post process to.
  75378. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  75379. */
  75380. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  75381. }
  75382. }
  75383. declare module BABYLON {
  75384. /** @hidden */
  75385. export var digitalrainPixelShader: {
  75386. name: string;
  75387. shader: string;
  75388. };
  75389. }
  75390. declare module BABYLON {
  75391. /**
  75392. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  75393. *
  75394. * It basically takes care rendering the font front the given font size to a texture.
  75395. * This is used later on in the postprocess.
  75396. */
  75397. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  75398. private _font;
  75399. private _text;
  75400. private _charSize;
  75401. /**
  75402. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  75403. */
  75404. readonly charSize: number;
  75405. /**
  75406. * Create a new instance of the Digital Rain FontTexture class
  75407. * @param name the name of the texture
  75408. * @param font the font to use, use the W3C CSS notation
  75409. * @param text the caracter set to use in the rendering.
  75410. * @param scene the scene that owns the texture
  75411. */
  75412. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  75413. /**
  75414. * Gets the max char width of a font.
  75415. * @param font the font to use, use the W3C CSS notation
  75416. * @return the max char width
  75417. */
  75418. private getFontWidth;
  75419. /**
  75420. * Gets the max char height of a font.
  75421. * @param font the font to use, use the W3C CSS notation
  75422. * @return the max char height
  75423. */
  75424. private getFontHeight;
  75425. /**
  75426. * Clones the current DigitalRainFontTexture.
  75427. * @return the clone of the texture.
  75428. */
  75429. clone(): DigitalRainFontTexture;
  75430. /**
  75431. * Parses a json object representing the texture and returns an instance of it.
  75432. * @param source the source JSON representation
  75433. * @param scene the scene to create the texture for
  75434. * @return the parsed texture
  75435. */
  75436. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  75437. }
  75438. /**
  75439. * Option available in the Digital Rain Post Process.
  75440. */
  75441. export interface IDigitalRainPostProcessOptions {
  75442. /**
  75443. * The font to use following the w3c font definition.
  75444. */
  75445. font?: string;
  75446. /**
  75447. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  75448. * This number is defined between 0 and 1;
  75449. */
  75450. mixToTile?: number;
  75451. /**
  75452. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  75453. * This number is defined between 0 and 1;
  75454. */
  75455. mixToNormal?: number;
  75456. }
  75457. /**
  75458. * DigitalRainPostProcess helps rendering everithing in digital rain.
  75459. *
  75460. * Simmply add it to your scene and let the nerd that lives in you have fun.
  75461. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  75462. */
  75463. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  75464. /**
  75465. * The font texture used to render the char in the post process.
  75466. */
  75467. private _digitalRainFontTexture;
  75468. /**
  75469. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  75470. * This number is defined between 0 and 1;
  75471. */
  75472. mixToTile: number;
  75473. /**
  75474. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  75475. * This number is defined between 0 and 1;
  75476. */
  75477. mixToNormal: number;
  75478. /**
  75479. * Instantiates a new Digital Rain Post Process.
  75480. * @param name the name to give to the postprocess
  75481. * @camera the camera to apply the post process to.
  75482. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  75483. */
  75484. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  75485. }
  75486. }
  75487. declare module BABYLON {
  75488. /** @hidden */
  75489. export var oceanPostProcessPixelShader: {
  75490. name: string;
  75491. shader: string;
  75492. };
  75493. }
  75494. declare module BABYLON {
  75495. /**
  75496. * Option available in the Ocean Post Process.
  75497. */
  75498. export interface IOceanPostProcessOptions {
  75499. /**
  75500. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  75501. */
  75502. reflectionSize?: number | {
  75503. width: number;
  75504. height: number;
  75505. } | {
  75506. ratio: number;
  75507. };
  75508. /**
  75509. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  75510. */
  75511. refractionSize?: number | {
  75512. width: number;
  75513. height: number;
  75514. } | {
  75515. ratio: number;
  75516. };
  75517. }
  75518. /**
  75519. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  75520. *
  75521. * Simmply add it to your scene and let the nerd that lives in you have fun.
  75522. * Example usage:
  75523. * var pp = new OceanPostProcess("myOcean", camera);
  75524. * pp.reflectionEnabled = true;
  75525. * pp.refractionEnabled = true;
  75526. */
  75527. export class OceanPostProcess extends BABYLON.PostProcess {
  75528. /**
  75529. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  75530. */
  75531. /**
  75532. * Sets weither or not the real-time reflection is enabled on the ocean.
  75533. * Is set to true, the reflection mirror texture will be used as reflection texture.
  75534. */
  75535. reflectionEnabled: boolean;
  75536. /**
  75537. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  75538. */
  75539. /**
  75540. * Sets weither or not the real-time refraction is enabled on the ocean.
  75541. * Is set to true, the refraction render target texture will be used as refraction texture.
  75542. */
  75543. refractionEnabled: boolean;
  75544. /**
  75545. * Gets wether or not the post-processes is supported by the running hardware.
  75546. * This requires draw buffer supports.
  75547. */
  75548. readonly isSupported: boolean;
  75549. /**
  75550. * This is the reflection mirror texture used to display reflections on the ocean.
  75551. * By default, render list is empty.
  75552. */
  75553. reflectionTexture: BABYLON.MirrorTexture;
  75554. /**
  75555. * This is the refraction render target texture used to display refraction on the ocean.
  75556. * By default, render list is empty.
  75557. */
  75558. refractionTexture: BABYLON.RenderTargetTexture;
  75559. private _time;
  75560. private _cameraRotation;
  75561. private _cameraViewMatrix;
  75562. private _reflectionEnabled;
  75563. private _refractionEnabled;
  75564. private _geometryRenderer;
  75565. /**
  75566. * Instantiates a new Ocean Post Process.
  75567. * @param name the name to give to the postprocess.
  75568. * @camera the camera to apply the post process to.
  75569. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  75570. */
  75571. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  75572. /**
  75573. * Returns the appropriate defines according to the current configuration.
  75574. */
  75575. private _getDefines;
  75576. /**
  75577. * Computes the current camera rotation as the shader requires a camera rotation.
  75578. */
  75579. private _computeCameraRotation;
  75580. }
  75581. }
  75582. declare module BABYLON {
  75583. /** @hidden */
  75584. export var brickProceduralTexturePixelShader: {
  75585. name: string;
  75586. shader: string;
  75587. };
  75588. }
  75589. declare module BABYLON {
  75590. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  75591. private _numberOfBricksHeight;
  75592. private _numberOfBricksWidth;
  75593. private _jointColor;
  75594. private _brickColor;
  75595. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75596. updateShaderUniforms(): void;
  75597. numberOfBricksHeight: number;
  75598. numberOfBricksWidth: number;
  75599. jointColor: BABYLON.Color3;
  75600. brickColor: BABYLON.Color3;
  75601. /**
  75602. * Serializes this brick procedural texture
  75603. * @returns a serialized brick procedural texture object
  75604. */
  75605. serialize(): any;
  75606. /**
  75607. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  75608. * @param parsedTexture defines parsed texture data
  75609. * @param scene defines the current scene
  75610. * @param rootUrl defines the root URL containing brick procedural texture information
  75611. * @returns a parsed Brick Procedural BABYLON.Texture
  75612. */
  75613. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  75614. }
  75615. }
  75616. declare module BABYLON {
  75617. /** @hidden */
  75618. export var cloudProceduralTexturePixelShader: {
  75619. name: string;
  75620. shader: string;
  75621. };
  75622. }
  75623. declare module BABYLON {
  75624. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  75625. private _skyColor;
  75626. private _cloudColor;
  75627. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75628. updateShaderUniforms(): void;
  75629. skyColor: BABYLON.Color4;
  75630. cloudColor: BABYLON.Color4;
  75631. /**
  75632. * Serializes this cloud procedural texture
  75633. * @returns a serialized cloud procedural texture object
  75634. */
  75635. serialize(): any;
  75636. /**
  75637. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  75638. * @param parsedTexture defines parsed texture data
  75639. * @param scene defines the current scene
  75640. * @param rootUrl defines the root URL containing cloud procedural texture information
  75641. * @returns a parsed Cloud Procedural BABYLON.Texture
  75642. */
  75643. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  75644. }
  75645. }
  75646. declare module BABYLON {
  75647. /** @hidden */
  75648. export var fireProceduralTexturePixelShader: {
  75649. name: string;
  75650. shader: string;
  75651. };
  75652. }
  75653. declare module BABYLON {
  75654. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  75655. private _time;
  75656. private _speed;
  75657. private _autoGenerateTime;
  75658. private _fireColors;
  75659. private _alphaThreshold;
  75660. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75661. updateShaderUniforms(): void;
  75662. render(useCameraPostProcess?: boolean): void;
  75663. static readonly PurpleFireColors: BABYLON.Color3[];
  75664. static readonly GreenFireColors: BABYLON.Color3[];
  75665. static readonly RedFireColors: BABYLON.Color3[];
  75666. static readonly BlueFireColors: BABYLON.Color3[];
  75667. autoGenerateTime: boolean;
  75668. fireColors: BABYLON.Color3[];
  75669. time: number;
  75670. speed: BABYLON.Vector2;
  75671. alphaThreshold: number;
  75672. /**
  75673. * Serializes this fire procedural texture
  75674. * @returns a serialized fire procedural texture object
  75675. */
  75676. serialize(): any;
  75677. /**
  75678. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  75679. * @param parsedTexture defines parsed texture data
  75680. * @param scene defines the current scene
  75681. * @param rootUrl defines the root URL containing fire procedural texture information
  75682. * @returns a parsed Fire Procedural BABYLON.Texture
  75683. */
  75684. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  75685. }
  75686. }
  75687. declare module BABYLON {
  75688. /** @hidden */
  75689. export var grassProceduralTexturePixelShader: {
  75690. name: string;
  75691. shader: string;
  75692. };
  75693. }
  75694. declare module BABYLON {
  75695. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  75696. private _grassColors;
  75697. private _groundColor;
  75698. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75699. updateShaderUniforms(): void;
  75700. grassColors: BABYLON.Color3[];
  75701. groundColor: BABYLON.Color3;
  75702. /**
  75703. * Serializes this grass procedural texture
  75704. * @returns a serialized grass procedural texture object
  75705. */
  75706. serialize(): any;
  75707. /**
  75708. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  75709. * @param parsedTexture defines parsed texture data
  75710. * @param scene defines the current scene
  75711. * @param rootUrl defines the root URL containing grass procedural texture information
  75712. * @returns a parsed Grass Procedural BABYLON.Texture
  75713. */
  75714. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  75715. }
  75716. }
  75717. declare module BABYLON {
  75718. /** @hidden */
  75719. export var marbleProceduralTexturePixelShader: {
  75720. name: string;
  75721. shader: string;
  75722. };
  75723. }
  75724. declare module BABYLON {
  75725. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  75726. private _numberOfTilesHeight;
  75727. private _numberOfTilesWidth;
  75728. private _amplitude;
  75729. private _jointColor;
  75730. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75731. updateShaderUniforms(): void;
  75732. numberOfTilesHeight: number;
  75733. amplitude: number;
  75734. numberOfTilesWidth: number;
  75735. jointColor: BABYLON.Color3;
  75736. /**
  75737. * Serializes this marble procedural texture
  75738. * @returns a serialized marble procedural texture object
  75739. */
  75740. serialize(): any;
  75741. /**
  75742. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  75743. * @param parsedTexture defines parsed texture data
  75744. * @param scene defines the current scene
  75745. * @param rootUrl defines the root URL containing marble procedural texture information
  75746. * @returns a parsed Marble Procedural BABYLON.Texture
  75747. */
  75748. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  75749. }
  75750. }
  75751. declare module BABYLON {
  75752. /** @hidden */
  75753. export var normalMapProceduralTexturePixelShader: {
  75754. name: string;
  75755. shader: string;
  75756. };
  75757. }
  75758. declare module BABYLON {
  75759. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  75760. private _baseTexture;
  75761. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75762. updateShaderUniforms(): void;
  75763. render(useCameraPostProcess?: boolean): void;
  75764. resize(size: any, generateMipMaps: any): void;
  75765. baseTexture: BABYLON.Texture;
  75766. /**
  75767. * Serializes this normal map procedural texture
  75768. * @returns a serialized normal map procedural texture object
  75769. */
  75770. serialize(): any;
  75771. /**
  75772. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  75773. * @param parsedTexture defines parsed texture data
  75774. * @param scene defines the current scene
  75775. * @param rootUrl defines the root URL containing normal map procedural texture information
  75776. * @returns a parsed Normal Map Procedural BABYLON.Texture
  75777. */
  75778. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  75779. }
  75780. }
  75781. declare module BABYLON {
  75782. /** @hidden */
  75783. export var perlinNoiseProceduralTexturePixelShader: {
  75784. name: string;
  75785. shader: string;
  75786. };
  75787. }
  75788. declare module BABYLON {
  75789. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  75790. time: number;
  75791. timeScale: number;
  75792. translationSpeed: number;
  75793. private _currentTranslation;
  75794. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75795. updateShaderUniforms(): void;
  75796. render(useCameraPostProcess?: boolean): void;
  75797. resize(size: any, generateMipMaps: any): void;
  75798. /**
  75799. * Serializes this perlin noise procedural texture
  75800. * @returns a serialized perlin noise procedural texture object
  75801. */
  75802. serialize(): any;
  75803. /**
  75804. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  75805. * @param parsedTexture defines parsed texture data
  75806. * @param scene defines the current scene
  75807. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  75808. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  75809. */
  75810. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  75811. }
  75812. }
  75813. declare module BABYLON {
  75814. /** @hidden */
  75815. export var roadProceduralTexturePixelShader: {
  75816. name: string;
  75817. shader: string;
  75818. };
  75819. }
  75820. declare module BABYLON {
  75821. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  75822. private _roadColor;
  75823. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75824. updateShaderUniforms(): void;
  75825. roadColor: BABYLON.Color3;
  75826. /**
  75827. * Serializes this road procedural texture
  75828. * @returns a serialized road procedural texture object
  75829. */
  75830. serialize(): any;
  75831. /**
  75832. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  75833. * @param parsedTexture defines parsed texture data
  75834. * @param scene defines the current scene
  75835. * @param rootUrl defines the root URL containing road procedural texture information
  75836. * @returns a parsed Road Procedural BABYLON.Texture
  75837. */
  75838. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  75839. }
  75840. }
  75841. declare module BABYLON {
  75842. /** @hidden */
  75843. export var starfieldProceduralTexturePixelShader: {
  75844. name: string;
  75845. shader: string;
  75846. };
  75847. }
  75848. declare module BABYLON {
  75849. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  75850. private _time;
  75851. private _alpha;
  75852. private _beta;
  75853. private _zoom;
  75854. private _formuparam;
  75855. private _stepsize;
  75856. private _tile;
  75857. private _brightness;
  75858. private _darkmatter;
  75859. private _distfading;
  75860. private _saturation;
  75861. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75862. updateShaderUniforms(): void;
  75863. time: number;
  75864. alpha: number;
  75865. beta: number;
  75866. formuparam: number;
  75867. stepsize: number;
  75868. zoom: number;
  75869. tile: number;
  75870. brightness: number;
  75871. darkmatter: number;
  75872. distfading: number;
  75873. saturation: number;
  75874. /**
  75875. * Serializes this starfield procedural texture
  75876. * @returns a serialized starfield procedural texture object
  75877. */
  75878. serialize(): any;
  75879. /**
  75880. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  75881. * @param parsedTexture defines parsed texture data
  75882. * @param scene defines the current scene
  75883. * @param rootUrl defines the root URL containing startfield procedural texture information
  75884. * @returns a parsed Starfield Procedural BABYLON.Texture
  75885. */
  75886. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  75887. }
  75888. }
  75889. declare module BABYLON {
  75890. /** @hidden */
  75891. export var woodProceduralTexturePixelShader: {
  75892. name: string;
  75893. shader: string;
  75894. };
  75895. }
  75896. declare module BABYLON {
  75897. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  75898. private _ampScale;
  75899. private _woodColor;
  75900. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75901. updateShaderUniforms(): void;
  75902. ampScale: number;
  75903. woodColor: BABYLON.Color3;
  75904. /**
  75905. * Serializes this wood procedural texture
  75906. * @returns a serialized wood procedural texture object
  75907. */
  75908. serialize(): any;
  75909. /**
  75910. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  75911. * @param parsedTexture defines parsed texture data
  75912. * @param scene defines the current scene
  75913. * @param rootUrl defines the root URL containing wood procedural texture information
  75914. * @returns a parsed Wood Procedural BABYLON.Texture
  75915. */
  75916. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  75917. }
  75918. }